diff options
author | Maxim Yurchuk <maxim-yurchuk@ydb.tech> | 2024-11-13 16:32:39 +0300 |
---|---|---|
committer | Maxim Yurchuk <maxim-yurchuk@ydb.tech> | 2024-11-13 16:32:39 +0300 |
commit | 23387aafadce23ea77beffb2981e8c0e2f2a7f0a (patch) | |
tree | 54b0f95fca1ad03d93f5a18abdfe98e8ab34b420 /library/cpp/yt/memory/ref.cpp | |
parent | ee51155da394b56a8e3329d25a514422e5da7bc3 (diff) | |
parent | 4ab23311f7a6d45ac318179569df9ba46fb9ab68 (diff) | |
download | ydb-23387aafadce23ea77beffb2981e8c0e2f2a7f0a.tar.gz |
Merge branch 'rightlib' into mergelibs-yurchuk-manual
Diffstat (limited to 'library/cpp/yt/memory/ref.cpp')
-rw-r--r-- | library/cpp/yt/memory/ref.cpp | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/library/cpp/yt/memory/ref.cpp b/library/cpp/yt/memory/ref.cpp index 4d02ef6875b..de04a83870e 100644 --- a/library/cpp/yt/memory/ref.cpp +++ b/library/cpp/yt/memory/ref.cpp @@ -46,6 +46,7 @@ private: //////////////////////////////////////////////////////////////////////////////// +template <class TString> class TStringHolder : public TSharedRangeHolder { @@ -232,11 +233,27 @@ TMutableRef TMutableRef::FromBlob(TBlob& blob) TSharedRef TSharedRef::FromString(TString str, TRefCountedTypeCookie tagCookie) { - auto holder = New<TStringHolder>(std::move(str), tagCookie); + return FromStringImpl(std::move(str), tagCookie); +} + +TSharedRef TSharedRef::FromString(std::string str, TRefCountedTypeCookie tagCookie) +{ + return FromStringImpl(std::move(str), tagCookie); +} + +template <class TString> +TSharedRef TSharedRef::FromStringImpl(TString str, TRefCountedTypeCookie tagCookie) +{ + auto holder = New<TStringHolder<TString>>(std::move(str), tagCookie); auto ref = TRef::FromString(holder->String()); return TSharedRef(ref, std::move(holder)); } +TSharedRef TSharedRef::FromString(const char* str) +{ + return FromString(std::string(str)); +} + TSharedRef TSharedRef::FromBlob(TBlob&& blob) { auto ref = TRef::FromBlob(blob); |