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

Method trimmed

valdi_core/src/valdi_core/cpp/Utils/StringBox.cpp:424–445  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

422}
423
424StringBox StringBox::trimmed() const noexcept {
425 size_t start = 0;
426 size_t end = length();
427
428 auto strView = toStringView();
429
430 while (start < end && Valdi::hasPrefix(strView, start, " ")) {
431 start++;
432 }
433
434 while (end > start && Valdi::hasSuffix(strView, " ")) {
435 end--;
436 strView = std::string_view(getCStr(), end);
437 }
438
439 if (start == 0 && end == length()) {
440 // Nothing changed.
441 return *this;
442 }
443
444 return StringCache::getGlobal().makeString(std::string_view(getCStr() + start, end - start));
445}
446
447const StringBox& StringBox::emptyString() {
448 static auto kEmptyString = StringBox();

Callers 3

getDeviceLocalesMethod · 0.80
sanitizeAssetNameFunction · 0.80
resolveMethod · 0.80

Calls 5

hasSuffixFunction · 0.85
getGlobalFunction · 0.85
makeStringMethod · 0.80
lengthFunction · 0.50
hasPrefixFunction · 0.50

Tested by

no test coverage detected