| 422 | } |
| 423 | |
| 424 | StringBox 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 | |
| 447 | const StringBox& StringBox::emptyString() { |
| 448 | static auto kEmptyString = StringBox(); |
no test coverage detected