aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/yt/yson_string/string-inl.h
diff options
context:
space:
mode:
authorbabenko <babenko@yandex-team.com>2023-01-20 22:13:39 +0300
committerbabenko <babenko@yandex-team.com>2023-01-20 22:13:39 +0300
commit991ef42e20b115accbc9d76e27c5c220d1c37095 (patch)
tree8a9e2ed1add9edfa4c2350be187c6859ae1631af /library/cpp/yt/yson_string/string-inl.h
parent980dc47153689172f8869a2a0d8dfe1014b2d70e (diff)
downloadydb-991ef42e20b115accbc9d76e27c5c220d1c37095.tar.gz
Refactor and improve TSharedRangeHolder
Diffstat (limited to 'library/cpp/yt/yson_string/string-inl.h')
-rw-r--r--library/cpp/yt/yson_string/string-inl.h29
1 files changed, 29 insertions, 0 deletions
diff --git a/library/cpp/yt/yson_string/string-inl.h b/library/cpp/yt/yson_string/string-inl.h
index 5c41629cc0..09db98881f 100644
--- a/library/cpp/yt/yson_string/string-inl.h
+++ b/library/cpp/yt/yson_string/string-inl.h
@@ -26,6 +26,35 @@ bool Equals(const TLeft& lhs, const TRight& rhs)
lhs.GetType() == rhs.GetType();
}
+class TYsonStringHolder
+ : public TSharedRangeHolder
+ , public TWithExtraSpace<TYsonStringHolder>
+{
+public:
+ explicit TYsonStringHolder(size_t size)
+ : Size_(size)
+ { }
+
+ char* GetData()
+ {
+ return static_cast<char*>(GetExtraSpacePtr());
+ }
+
+ // TSharedRangeHolder overrides.
+ std::optional<size_t> GetTotalByteSize() const override
+ {
+ return Size_ + sizeof(TYsonStringHolder);
+ }
+
+ static TIntrusivePtr<TYsonStringHolder> Allocate(size_t size)
+ {
+ return NewWithExtraSpace<TYsonStringHolder>(size, size);
+ }
+
+private:
+ const size_t Size_;
+};
+
} // namespace NDetail
inline bool operator == (const TYsonString& lhs, const TYsonString& rhs)