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 | f31097c96270919a1f49360bdaaa69ea4f3fefab (patch) | |
tree | 5d5cb817648f650d76cf1076100726fd9b8448e8 /util | |
parent | cec37806d8847aa3db53bafc9e251d4aaf325c12 (diff) | |
download | ydb-f31097c96270919a1f49360bdaaa69ea4f3fefab.tar.gz |
Restoring authorship annotation for <babenko@yandex-team.ru>. Commit 2 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 70abda0c9f..e20bd908e4 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 050d291c43..e8088cf23b 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 ddb2e8f825..0551d58770 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 f2319d9a66..af2630890a 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_); } |