diff options
author | babenko <babenko@yandex-team.com> | 2025-02-22 17:28:25 +0300 |
---|---|---|
committer | babenko <babenko@yandex-team.com> | 2025-02-22 17:48:29 +0300 |
commit | 59afaa0cb7cd89146dd10f5446256afcce33bd0e (patch) | |
tree | 38d3c46bcba8da7c3b8ffc6b818695bc6b62d532 /library/cpp/yt/error/error_code.cpp | |
parent | 1d9cc117e33b162a5247032e175ed7ea26971437 (diff) | |
download | ydb-59afaa0cb7cd89146dd10f5446256afcce33bd0e.tar.gz |
YT-22593: More trivial TString->std::string migrations
[nodiff:runtime]
commit_hash:1ba799aed1703ab7c6304b6da7090b3337f768dd
Diffstat (limited to 'library/cpp/yt/error/error_code.cpp')
-rw-r--r-- | library/cpp/yt/error/error_code.cpp | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/library/cpp/yt/error/error_code.cpp b/library/cpp/yt/error/error_code.cpp index 9cb0d57dc2..d82d03214d 100644 --- a/library/cpp/yt/error/error_code.cpp +++ b/library/cpp/yt/error/error_code.cpp @@ -85,7 +85,7 @@ bool TErrorCodeRegistry::TErrorCodeRangeInfo::Contains(int value) const return From <= value && value <= To; } -void TErrorCodeRegistry::RegisterErrorCodeRange(int from, int to, TString namespaceName, std::function<TString(int)> formatter) +void TErrorCodeRegistry::RegisterErrorCodeRange(int from, int to, std::string namespaceName, std::function<std::string(int)> formatter) { YT_VERIFY(from <= to); @@ -117,24 +117,26 @@ void TErrorCodeRegistry::CheckCodesAgainstRanges() const } } -TString TErrorCodeRegistry::ParseNamespace(const std::type_info& errorCodeEnumTypeInfo) +std::string TErrorCodeRegistry::ParseNamespace(const std::type_info& errorCodeEnumTypeInfo) { - TString name; + std::string name; // Ensures that "EErrorCode" is found as a substring in the type name and stores the prefix before // the first occurrence into #name. YT_VERIFY(StringSplitter( TypeName(errorCodeEnumTypeInfo)).SplitByString("EErrorCode").Limit(2).TryCollectInto(&name, &std::ignore)); // TypeName returns name in form "enum ErrorCode" on Windows - if (name.StartsWith("enum ")) { - name.remove(0, 5); + constexpr TStringBuf enumPrefix = "enum "; + if (name.starts_with(enumPrefix)) { + name.erase(0, enumPrefix.size()); } // If the enum was declared directly in the global namespace, #name should be empty. // Otherwise, #name should end with "::". + constexpr TStringBuf namespaceSeparator = "::"; if (!name.empty()) { - YT_VERIFY(name.EndsWith("::")); - name.resize(name.size() - 2); + YT_VERIFY(name.ends_with(namespaceSeparator)); + name.resize(name.size() - namespaceSeparator.size()); } return name; } |