| 206 | } |
| 207 | |
| 208 | StringBox StringBox::replacing(char c, char replacement) const noexcept { |
| 209 | if (!contains(c)) { |
| 210 | // Avoid copies if character is not found |
| 211 | return *this; |
| 212 | } |
| 213 | |
| 214 | auto out = slowToString(); |
| 215 | |
| 216 | for (char& existingChar : out) { |
| 217 | if (existingChar == c) { |
| 218 | existingChar = replacement; |
| 219 | } |
| 220 | } |
| 221 | |
| 222 | return StringCache::getGlobal().makeString(std::move(out)); |
| 223 | } |
| 224 | |
| 225 | StringBox StringBox::prepend(const StringBox& other) const noexcept { |
| 226 | return prepend(other.toStringView()); |
no test coverage detected