diff options
author | babenko <babenko@yandex-team.com> | 2022-12-04 19:31:32 +0300 |
---|---|---|
committer | babenko <babenko@yandex-team.com> | 2022-12-04 19:31:32 +0300 |
commit | 3680ca61e6e893b6ddbba096616c807efd3d7c2b (patch) | |
tree | 0e46d6e15ed4cec31b2fe9c7b8d8d89c2305b728 /library/cpp/yt/memory/ref.cpp | |
parent | 7adf7eaadc3fe5a045969aa96ef3abe6ba2bf3a3 (diff) | |
download | ydb-3680ca61e6e893b6ddbba096616c807efd3d7c2b.tar.gz |
Add TSharedRefArray::ToString
Diffstat (limited to 'library/cpp/yt/memory/ref.cpp')
-rw-r--r-- | library/cpp/yt/memory/ref.cpp | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/library/cpp/yt/memory/ref.cpp b/library/cpp/yt/memory/ref.cpp index aff7baedd3..d167247c20 100644 --- a/library/cpp/yt/memory/ref.cpp +++ b/library/cpp/yt/memory/ref.cpp @@ -332,6 +332,27 @@ std::vector<TSharedRef> TSharedRefArray::ToVector() const return std::vector<TSharedRef>(Begin(), End()); } +TString TSharedRefArray::ToString() const +{ + if (!Impl_) { + return {}; + } + + TString result; + size_t size = 0; + for (const auto& part : *this) { + size += part.size(); + } + result.ReserveAndResize(size); + char* ptr = result.begin(); + for (const auto& part : *this) { + size += part.size(); + ::memcpy(ptr, part.begin(), part.size()); + ptr += part.size(); + } + return result; +} + //////////////////////////////////////////////////////////////////////////////// TSharedRefArrayBuilder::TSharedRefArrayBuilder( |