diff options
author | babenko <babenko@yandex-team.ru> | 2022-02-10 16:49:19 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:49:19 +0300 |
commit | cec37806d8847aa3db53bafc9e251d4aaf325c12 (patch) | |
tree | 4a61c191e93e31d9ab423e258c71ab43550ee3d2 /util | |
parent | 58cd0b86ed99a72df22479e26a20bc1c1e57e65e (diff) | |
download | ydb-cec37806d8847aa3db53bafc9e251d4aaf325c12.tar.gz |
Restoring authorship annotation for <babenko@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'util')
-rw-r--r-- | util/digest/numeric.h | 4 | ||||
-rw-r--r-- | util/generic/hash_set.h | 8 | ||||
-rw-r--r-- | util/generic/hash_ut.cpp | 94 | ||||
-rw-r--r-- | util/system/spinlock.h | 2 |
4 files changed, 54 insertions, 54 deletions
diff --git a/util/digest/numeric.h b/util/digest/numeric.h index e20bd908e4..70abda0c9f 100644 --- a/util/digest/numeric.h +++ b/util/digest/numeric.h @@ -73,9 +73,9 @@ static constexpr size_t NumericHash(T t) noexcept { using TCvt = TFixedWidthUnsignedInt<T>; union Y_HIDDEN { - T t; + T t; TCvt cvt; - } u{t}; + } u{t}; return (size_t)IntHash(u.cvt); } diff --git a/util/generic/hash_set.h b/util/generic/hash_set.h index e8088cf23b..050d291c43 100644 --- a/util/generic/hash_set.h +++ b/util/generic/hash_set.h @@ -399,10 +399,10 @@ public: iterator insert(const value_type& obj) { return rep.insert_equal(obj); } - template <typename... Args> - iterator emplace(Args&&... args) { - return rep.emplace_equal(std::forward<Args>(args)...); - } + template <typename... Args> + iterator emplace(Args&&... args) { + return rep.emplace_equal(std::forward<Args>(args)...); + } template <class InputIterator> void insert(InputIterator f, InputIterator l) { rep.insert_equal(f, l); diff --git a/util/generic/hash_ut.cpp b/util/generic/hash_ut.cpp index 0551d58770..ddb2e8f825 100644 --- a/util/generic/hash_ut.cpp +++ b/util/generic/hash_ut.cpp @@ -2,7 +2,7 @@ #include "vector.h" #include "hash_set.h" -#include <library/cpp/testing/common/probe.h> +#include <library/cpp/testing/common/probe.h> #include <library/cpp/testing/unittest/registar.h> #include <utility> @@ -28,7 +28,7 @@ class THashTest: public TTestBase { UNIT_TEST(TestHMSetSize); UNIT_TEST(TestHMSet1); UNIT_TEST(TestHMSetEqualityOperator); - UNIT_TEST(TestHMSetEmplace); + UNIT_TEST(TestHMSetEmplace); UNIT_TEST(TestInsertErase); UNIT_TEST(TestResizeOnInsertSmartPtrBug) UNIT_TEST(TestEmpty); @@ -79,7 +79,7 @@ protected: void TestHMSetSize(); void TestHMSet1(); void TestHMSetEqualityOperator(); - void TestHMSetEmplace(); + void TestHMSetEmplace(); void TestInsertErase(); void TestResizeOnInsertSmartPtrBug(); void TestEmpty(); @@ -554,56 +554,56 @@ void THashTest::TestHMSetEqualityOperator() { UNIT_ASSERT(!(c3 == base)); } -void THashTest::TestHMSetEmplace() { - class TKey: public NTesting::TProbe { - public: - TKey(NTesting::TProbeState* state, int key) - : TProbe(state) +void THashTest::TestHMSetEmplace() { + class TKey: public NTesting::TProbe { + public: + TKey(NTesting::TProbeState* state, int key) + : TProbe(state) , Key_(key) { } - - operator size_t() const { + + operator size_t() const { return THash<int>()(Key_); - } - - bool operator==(const TKey& other) const { + } + + bool operator==(const TKey& other) const { return Key_ == other.Key_; - } - - private: + } + + private: int Key_; - }; - - NTesting::TProbeState state; - - { - THashMultiSet<TKey> c; - c.emplace(&state, 1); - c.emplace(&state, 1); - c.emplace(&state, 2); - - UNIT_ASSERT_EQUAL(state.CopyAssignments, 0); - UNIT_ASSERT_EQUAL(state.MoveAssignments, 0); - UNIT_ASSERT_EQUAL(state.Constructors, 3); - UNIT_ASSERT_EQUAL(state.MoveConstructors, 0); - - UNIT_ASSERT_EQUAL(c.count(TKey(&state, 1)), 2); - UNIT_ASSERT_EQUAL(c.count(TKey(&state, 2)), 1); - UNIT_ASSERT_EQUAL(c.count(TKey(&state, 3)), 0); - - UNIT_ASSERT_EQUAL(state.Constructors, 6); - UNIT_ASSERT_EQUAL(state.Destructors, 3); - } - - UNIT_ASSERT_EQUAL(state.CopyAssignments, 0); - UNIT_ASSERT_EQUAL(state.MoveAssignments, 0); - UNIT_ASSERT_EQUAL(state.CopyConstructors, 0); - UNIT_ASSERT_EQUAL(state.MoveConstructors, 0); - UNIT_ASSERT_EQUAL(state.Constructors, 6); - UNIT_ASSERT_EQUAL(state.Destructors, 6); -} - + }; + + NTesting::TProbeState state; + + { + THashMultiSet<TKey> c; + c.emplace(&state, 1); + c.emplace(&state, 1); + c.emplace(&state, 2); + + UNIT_ASSERT_EQUAL(state.CopyAssignments, 0); + UNIT_ASSERT_EQUAL(state.MoveAssignments, 0); + UNIT_ASSERT_EQUAL(state.Constructors, 3); + UNIT_ASSERT_EQUAL(state.MoveConstructors, 0); + + UNIT_ASSERT_EQUAL(c.count(TKey(&state, 1)), 2); + UNIT_ASSERT_EQUAL(c.count(TKey(&state, 2)), 1); + UNIT_ASSERT_EQUAL(c.count(TKey(&state, 3)), 0); + + UNIT_ASSERT_EQUAL(state.Constructors, 6); + UNIT_ASSERT_EQUAL(state.Destructors, 3); + } + + UNIT_ASSERT_EQUAL(state.CopyAssignments, 0); + UNIT_ASSERT_EQUAL(state.MoveAssignments, 0); + UNIT_ASSERT_EQUAL(state.CopyConstructors, 0); + UNIT_ASSERT_EQUAL(state.MoveConstructors, 0); + UNIT_ASSERT_EQUAL(state.Constructors, 6); + UNIT_ASSERT_EQUAL(state.Destructors, 6); +} + void THashTest::TestInsertErase() { using hmap = THashMap<TString, size_t, THash<TString>, TEqualTo<TString>>; using val_type = hmap::value_type; diff --git a/util/system/spinlock.h b/util/system/spinlock.h index af2630890a..f2319d9a66 100644 --- a/util/system/spinlock.h +++ b/util/system/spinlock.h @@ -10,7 +10,7 @@ protected: } public: - inline bool IsLocked() const noexcept { + inline bool IsLocked() const noexcept { return AtomicGet(Val_); } |