MCPcopy Create free account
hub / github.com/Snapchat/Valdi / replacing

Method replacing

valdi_core/src/valdi_core/cpp/Utils/StringBox.cpp:208–223  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

206}
207
208StringBox 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
225StringBox StringBox::prepend(const StringBox& other) const noexcept {
226 return prepend(other.toStringView());

Calls 4

containsFunction · 0.85
slowToStringFunction · 0.85
getGlobalFunction · 0.85
makeStringMethod · 0.80

Tested by

no test coverage detected