diff options
| author | babenko <[email protected]> | 2025-12-24 23:29:35 +0300 |
|---|---|---|
| committer | babenko <[email protected]> | 2025-12-24 23:45:58 +0300 |
| commit | 4dbf62fd2f8cc5ece53cc1446561cf71476bdd12 (patch) | |
| tree | 9aab73c043bf8f6dc177b06f69dab4336dadfcba /library/cpp/containers/cow_string/reverse.cpp | |
| parent | dba8986f6b1a5fc7c4f230bee510113995a48970 (diff) | |
Explicitly use TCowString in TYsonString
Для ревьюеров: изменения вне `library/cpp/yt` убирают `using namespace NYT` из хедера. Эта конструкция приводила к клешу имен глобального неймспейса и `NYT` и ошибкам сборки.
commit_hash:f598da488a6dd8671af9f1f02870ab5612ae46eb
Diffstat (limited to 'library/cpp/containers/cow_string/reverse.cpp')
| -rw-r--r-- | library/cpp/containers/cow_string/reverse.cpp | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/library/cpp/containers/cow_string/reverse.cpp b/library/cpp/containers/cow_string/reverse.cpp new file mode 100644 index 00000000000..b5bd10d250a --- /dev/null +++ b/library/cpp/containers/cow_string/reverse.cpp @@ -0,0 +1,32 @@ +#include "reverse.h" + +#include <util/generic/vector.h> +#include <util/charset/wide_specific.h> + +#include <algorithm> + +void ReverseInPlace(TCowString& string) { + auto* begin = string.begin(); + std::reverse(begin, begin + string.size()); +} + +void ReverseInPlace(TUtf16CowString& string) { + auto* begin = string.begin(); + const auto len = string.size(); + auto* end = begin + string.size(); + + TVector<wchar16> buffer(len); + wchar16* rbegin = buffer.data() + len; + for (wchar16* p = begin; p < end;) { + const size_t symbolSize = W16SymbolSize(p, end); + rbegin -= symbolSize; + std::copy(p, p + symbolSize, rbegin); + p += symbolSize; + } + std::copy(buffer.begin(), buffer.end(), begin); +} + +void ReverseInPlace(TUtf32CowString& string) { + auto* begin = string.begin(); + std::reverse(begin, begin + string.size()); +} |
