aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/yt/memory/ref.cpp
diff options
context:
space:
mode:
authorbabenko <babenko@yandex-team.com>2022-12-04 19:31:32 +0300
committerbabenko <babenko@yandex-team.com>2022-12-04 19:31:32 +0300
commit3680ca61e6e893b6ddbba096616c807efd3d7c2b (patch)
tree0e46d6e15ed4cec31b2fe9c7b8d8d89c2305b728 /library/cpp/yt/memory/ref.cpp
parent7adf7eaadc3fe5a045969aa96ef3abe6ba2bf3a3 (diff)
downloadydb-3680ca61e6e893b6ddbba096616c807efd3d7c2b.tar.gz
Add TSharedRefArray::ToString
Diffstat (limited to 'library/cpp/yt/memory/ref.cpp')
-rw-r--r--library/cpp/yt/memory/ref.cpp21
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(