diff options
author | sobols <sobols@yandex-team.com> | 2022-10-25 18:08:39 +0300 |
---|---|---|
committer | sobols <sobols@yandex-team.com> | 2022-10-25 18:08:39 +0300 |
commit | c65f97c0e29659449217343bf981afdda430b75b (patch) | |
tree | 91710e4f0ca87dda17f2d1346ba829787cdb8c0f /library/cpp/containers | |
parent | 70dc14cf15259cb9aec11c59e26cc56848640dcc (diff) | |
download | ydb-c65f97c0e29659449217343bf981afdda430b75b.tar.gz |
[comptrie] Use std::move with TBlob (clang-tidy modernize-pass-by-value)
TBlob is ref-counted, moving it may be faster than copying.
Diffstat (limited to 'library/cpp/containers')
-rw-r--r-- | library/cpp/containers/comptrie/comptrie_trie.h | 25 |
1 files changed, 11 insertions, 14 deletions
diff --git a/library/cpp/containers/comptrie/comptrie_trie.h b/library/cpp/containers/comptrie/comptrie_trie.h index 40ec1e52b3..a3f1fcfb5c 100644 --- a/library/cpp/containers/comptrie/comptrie_trie.h +++ b/library/cpp/containers/comptrie/comptrie_trie.h @@ -59,9 +59,9 @@ public: : TCompactTrie{d, len, TPacker{}} { } - TCompactTrie(const TBlob& data, TPacker packer); - explicit TCompactTrie(const TBlob& data) - : TCompactTrie{data, TPacker{}} { + TCompactTrie(TBlob data, TPacker packer); + explicit TCompactTrie(TBlob data) + : TCompactTrie{std::move(data), TPacker{}} { } // Skipper should be initialized with &Packer, not with &other.Packer, so you have to redefine these. @@ -75,7 +75,7 @@ public: } void Init(const char* d, size_t len, TPacker packer = TPacker()); - void Init(const TBlob& data, TPacker packer = TPacker()); + void Init(TBlob data, TPacker packer = TPacker()); bool IsInitialized() const; bool IsEmpty() const; @@ -195,7 +195,7 @@ public: protected: explicit TCompactTrie(const char* emptyValue); - TCompactTrie(const TBlob& data, const char* emptyValue, TPacker packer = TPacker()); + TCompactTrie(TBlob data, const char* emptyValue, TPacker packer = TPacker()); bool LookupLongestPrefix(const TSymbol* key, size_t keylen, size_t& prefixLen, const char*& valuepos, bool& hasNext) const; bool LookupLongestPrefix(const TSymbol* key, size_t keylen, size_t& prefixLen, const char*& valuepos) const { @@ -222,16 +222,13 @@ public: // TCompactTrie template <class T, class D, class S> -TCompactTrie<T, D, S>::TCompactTrie(const TBlob& data, TPacker packer) - : DataHolder(data) - , Packer(packer) +TCompactTrie<T, D, S>::TCompactTrie(TBlob data, TPacker packer) { - Init(data, packer); + Init(std::move(data), packer); } template <class T, class D, class S> TCompactTrie<T, D, S>::TCompactTrie(const char* d, size_t len, TPacker packer) - : Packer(packer) { Init(d, len, packer); } @@ -243,8 +240,8 @@ TCompactTrie<T, D, S>::TCompactTrie(const char* emptyValue) } template <class T, class D, class S> -TCompactTrie<T, D, S>::TCompactTrie(const TBlob& data, const char* emptyValue, TPacker packer) - : DataHolder(data) +TCompactTrie<T, D, S>::TCompactTrie(TBlob data, const char* emptyValue, TPacker packer) + : DataHolder(std::move(data)) , EmptyValue(emptyValue) , Packer(packer) { @@ -292,10 +289,10 @@ void TCompactTrie<T, D, S>::Init(const char* d, size_t len, TPacker packer) { } template <class T, class D, class S> -void TCompactTrie<T, D, S>::Init(const TBlob& data, TPacker packer) { +void TCompactTrie<T, D, S>::Init(TBlob data, TPacker packer) { using namespace NCompactTrie; - DataHolder = data; + DataHolder = std::move(data); Packer = packer; const char* datapos = DataHolder.AsCharPtr(); |