diff options
author | yazevnul <yazevnul@yandex-team.ru> | 2022-02-10 16:46:46 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:46:46 +0300 |
commit | 8cbc307de0221f84c80c42dcbe07d40727537e2c (patch) | |
tree | 625d5a673015d1df891e051033e9fcde5c7be4e5 /util/digest | |
parent | 30d1ef3941e0dc835be7609de5ebee66958f215a (diff) | |
download | ydb-8cbc307de0221f84c80c42dcbe07d40727537e2c.tar.gz |
Restoring authorship annotation for <yazevnul@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'util/digest')
-rw-r--r-- | util/digest/city.cpp | 4 | ||||
-rw-r--r-- | util/digest/city.h | 44 | ||||
-rw-r--r-- | util/digest/fnv.h | 16 | ||||
-rw-r--r-- | util/digest/multi.h | 2 | ||||
-rw-r--r-- | util/digest/multi_ut.cpp | 2 | ||||
-rw-r--r-- | util/digest/murmur.cpp | 4 | ||||
-rw-r--r-- | util/digest/murmur_ut.cpp | 2 | ||||
-rw-r--r-- | util/digest/numeric.h | 18 | ||||
-rw-r--r-- | util/digest/sequence.h | 2 | ||||
-rw-r--r-- | util/digest/sequence_ut.cpp | 2 |
10 files changed, 48 insertions, 48 deletions
diff --git a/util/digest/city.cpp b/util/digest/city.cpp index c25f175d54..7596cd96a0 100644 --- a/util/digest/city.cpp +++ b/util/digest/city.cpp @@ -201,7 +201,7 @@ uint64 CityHash64WithSeed(const char* s, size_t len, uint64 seed) noexcept { } uint64 CityHash64WithSeeds(const char* s, size_t len, - uint64 seed0, uint64 seed1) noexcept { + uint64 seed0, uint64 seed1) noexcept { return HashLen16(CityHash64(s, len) - seed0, seed1); } @@ -310,7 +310,7 @@ uint128 CityHash128(const char* s, size_t len) noexcept { } } -// TODO(yazevnul): move this function to unittests +// TODO(yazevnul): move this function to unittests void TestCompilationOfCityHashTemplates() { TStringBuf s; CityHash64(s); diff --git a/util/digest/city.h b/util/digest/city.h index 675a798074..2d8cd8ead1 100644 --- a/util/digest/city.h +++ b/util/digest/city.h @@ -5,16 +5,16 @@ #include <utility> -// NOTE: These functions provide CityHash 1.0 implementation whose results are *different* from -// the mainline version of CityHash. - +// NOTE: These functions provide CityHash 1.0 implementation whose results are *different* from +// the mainline version of CityHash. + using uint128 = std::pair<ui64, ui64>; -constexpr ui64 Uint128Low64(const uint128& x) { +constexpr ui64 Uint128Low64(const uint128& x) { return x.first; } -constexpr ui64 Uint128High64(const uint128& x) { +constexpr ui64 Uint128High64(const uint128& x) { return x.second; } @@ -33,7 +33,7 @@ Y_PURE_FUNCTION uint128 CityHash128WithSeed(const char* s, size_t len, uint128 s // Hash 128 input bits down to 64 bits of output. // This is intended to be a reasonably good hash function. -inline ui64 Hash128to64(const uint128& x) { +inline ui64 Hash128to64(const uint128& x) { // Murmur-inspired hashing. const ui64 kMul = 0x9ddfea08eb382d69ULL; ui64 a = (Uint128Low64(x) ^ Uint128High64(x)) * kMul; @@ -44,40 +44,40 @@ inline ui64 Hash128to64(const uint128& x) { return b; } -namespace NPrivateCityHash { - template <class TStringType> - inline TStringBuf GetBufFromStr(const TStringType& str) { - static_assert(std::is_integral<std::remove_reference_t<decltype(*str.data())>>::value, "invalid type passed to hash function"); - return TStringBuf(reinterpret_cast<const char*>(str.data()), (str.size()) * sizeof(*str.data())); - } +namespace NPrivateCityHash { + template <class TStringType> + inline TStringBuf GetBufFromStr(const TStringType& str) { + static_assert(std::is_integral<std::remove_reference_t<decltype(*str.data())>>::value, "invalid type passed to hash function"); + return TStringBuf(reinterpret_cast<const char*>(str.data()), (str.size()) * sizeof(*str.data())); + } } template <class TStringType> inline ui64 CityHash64(const TStringType& str) { - TStringBuf buf = NPrivateCityHash::GetBufFromStr(str); - return CityHash64(buf.data(), buf.size()); + TStringBuf buf = NPrivateCityHash::GetBufFromStr(str); + return CityHash64(buf.data(), buf.size()); } template <class TStringType> inline ui64 CityHash64WithSeeds(const TStringType& str, ui64 seed0, ui64 seed1) { - TStringBuf buf = NPrivateCityHash::GetBufFromStr(str); - return CityHash64WithSeeds(buf.data(), buf.size(), seed0, seed1); + TStringBuf buf = NPrivateCityHash::GetBufFromStr(str); + return CityHash64WithSeeds(buf.data(), buf.size(), seed0, seed1); } template <class TStringType> inline ui64 CityHash64WithSeed(const TStringType& str, ui64 seed) { - TStringBuf buf = NPrivateCityHash::GetBufFromStr(str); - return CityHash64WithSeed(buf.data(), buf.size(), seed); + TStringBuf buf = NPrivateCityHash::GetBufFromStr(str); + return CityHash64WithSeed(buf.data(), buf.size(), seed); } template <class TStringType> inline uint128 CityHash128(const TStringType& str) { - TStringBuf buf = NPrivateCityHash::GetBufFromStr(str); - return CityHash128(buf.data(), buf.size()); + TStringBuf buf = NPrivateCityHash::GetBufFromStr(str); + return CityHash128(buf.data(), buf.size()); } template <class TStringType> inline uint128 CityHash128WithSeed(const TStringType& str, uint128 seed) { - TStringBuf buf = NPrivateCityHash::GetBufFromStr(str); - return CityHash128WithSeed(buf.data(), buf.size(), seed); + TStringBuf buf = NPrivateCityHash::GetBufFromStr(str); + return CityHash128WithSeed(buf.data(), buf.size(), seed); } diff --git a/util/digest/fnv.h b/util/digest/fnv.h index 87b41a3de7..957ba9b9f1 100644 --- a/util/digest/fnv.h +++ b/util/digest/fnv.h @@ -9,7 +9,7 @@ namespace NFnvPrivate { template <class It> - constexpr ui32 FnvHash32(It b, It e, ui32 init) { + constexpr ui32 FnvHash32(It b, It e, ui32 init) { while (b != e) { init = (init * FNV32PRIME) ^ (unsigned char)*b++; } @@ -18,7 +18,7 @@ namespace NFnvPrivate { } template <class It> - constexpr ui64 FnvHash64(It b, It e, ui64 init) { + constexpr ui64 FnvHash64(It b, It e, ui64 init) { while (b != e) { init = (init * FNV64PRIME) ^ (unsigned char)*b++; } @@ -34,7 +34,7 @@ namespace NFnvPrivate { struct TFnvHelper<t> { \ static const ui##t Init = FNV##t##INIT; \ template <class It> \ - static constexpr ui##t FnvHash(It b, It e, ui##t init) { \ + static constexpr ui##t FnvHash(It b, It e, ui##t init) { \ return FnvHash##t(b, e, init); \ } \ }; @@ -46,28 +46,28 @@ namespace NFnvPrivate { } template <class T, class It> -static constexpr T FnvHash(It b, It e, T init) { +static constexpr T FnvHash(It b, It e, T init) { static_assert(sizeof(*b) == 1, "expect sizeof(*b) == 1"); return (T)NFnvPrivate::TFnvHelper<8 * sizeof(T)>::FnvHash(b, e, init); } template <class T, class It> -static constexpr T FnvHash(It b, It e) { +static constexpr T FnvHash(It b, It e) { return FnvHash<T>(b, e, (T)NFnvPrivate::TFnvHelper<8 * sizeof(T)>::Init); } template <class T> -static constexpr T FnvHash(const void* buf, size_t len, T init) { +static constexpr T FnvHash(const void* buf, size_t len, T init) { return FnvHash<T>((const unsigned char*)buf, (const unsigned char*)buf + len, init); } template <class T> -static constexpr T FnvHash(const void* buf, size_t len) { +static constexpr T FnvHash(const void* buf, size_t len) { return FnvHash<T>((const unsigned char*)buf, (const unsigned char*)buf + len); } template <class T, class Buf> -static constexpr T FnvHash(const Buf& buf) { +static constexpr T FnvHash(const Buf& buf) { return FnvHash<T>(buf.data(), buf.size() * sizeof(*buf.data())); } diff --git a/util/digest/multi.h b/util/digest/multi.h index 8e4597c9dc..92de71e783 100644 --- a/util/digest/multi.h +++ b/util/digest/multi.h @@ -5,7 +5,7 @@ #include "numeric.h" template <typename TOne> -constexpr size_t MultiHash(const TOne& one) noexcept { +constexpr size_t MultiHash(const TOne& one) noexcept { return THash<TOne>()(one); } template <typename THead, typename... TTail> diff --git a/util/digest/multi_ut.cpp b/util/digest/multi_ut.cpp index dff64ff0cc..71c188c39a 100644 --- a/util/digest/multi_ut.cpp +++ b/util/digest/multi_ut.cpp @@ -2,7 +2,7 @@ #include <library/cpp/testing/unittest/registar.h> -#include <util/stream/output.h> +#include <util/stream/output.h> class TMultiHashTest: public TTestBase { UNIT_TEST_SUITE(TMultiHashTest); diff --git a/util/digest/murmur.cpp b/util/digest/murmur.cpp index b041d3e5f2..8fe21d3a04 100644 --- a/util/digest/murmur.cpp +++ b/util/digest/murmur.cpp @@ -1,7 +1,7 @@ #include "murmur.h" -#include <util/system/unaligned_mem.h> - +#include <util/system/unaligned_mem.h> + namespace NMurmurPrivate { //----------------------------------------------------------------------------- // MurmurHash2, by Austin Appleby diff --git a/util/digest/murmur_ut.cpp b/util/digest/murmur_ut.cpp index 29287668bc..ecb10a9dac 100644 --- a/util/digest/murmur_ut.cpp +++ b/util/digest/murmur_ut.cpp @@ -76,7 +76,7 @@ private: } template <class E, class T> - inline void TestWrapper(const TArrayRef<E>& array, T expected) { + inline void TestWrapper(const TArrayRef<E>& array, T expected) { auto val = TMurmurHash<T>()(array); UNIT_ASSERT_EQUAL(val, expected); } diff --git a/util/digest/numeric.h b/util/digest/numeric.h index e20bd908e4..59b60d1c2e 100644 --- a/util/digest/numeric.h +++ b/util/digest/numeric.h @@ -8,7 +8,7 @@ * copy: https://gist.github.com/badboy/6267743 */ -static constexpr ui8 IntHashImpl(ui8 key8) noexcept { +static constexpr ui8 IntHashImpl(ui8 key8) noexcept { size_t key = key8; key += ~(key << 15); @@ -21,7 +21,7 @@ static constexpr ui8 IntHashImpl(ui8 key8) noexcept { return static_cast<ui8>(key); } -static constexpr ui16 IntHashImpl(ui16 key16) noexcept { +static constexpr ui16 IntHashImpl(ui16 key16) noexcept { size_t key = key16; key += ~(key << 15); @@ -34,7 +34,7 @@ static constexpr ui16 IntHashImpl(ui16 key16) noexcept { return static_cast<ui16>(key); } -static constexpr ui32 IntHashImpl(ui32 key) noexcept { +static constexpr ui32 IntHashImpl(ui32 key) noexcept { key += ~(key << 15); key ^= (key >> 10); key += (key << 3); @@ -45,7 +45,7 @@ static constexpr ui32 IntHashImpl(ui32 key) noexcept { return key; } -static constexpr ui64 IntHashImpl(ui64 key) noexcept { +static constexpr ui64 IntHashImpl(ui64 key) noexcept { key += ~(key << 32); key ^= (key >> 22); key += ~(key << 13); @@ -59,8 +59,8 @@ static constexpr ui64 IntHashImpl(ui64 key) noexcept { } template <class T> -static constexpr T IntHash(T t) noexcept { - using TCvt = TFixedWidthUnsignedInt<T>; +static constexpr T IntHash(T t) noexcept { + using TCvt = TFixedWidthUnsignedInt<T>; return IntHashImpl((TCvt)(t)); } @@ -69,8 +69,8 @@ static constexpr T IntHash(T t) noexcept { * can handle floats && pointers */ template <class T> -static constexpr size_t NumericHash(T t) noexcept { - using TCvt = TFixedWidthUnsignedInt<T>; +static constexpr size_t NumericHash(T t) noexcept { + using TCvt = TFixedWidthUnsignedInt<T>; union Y_HIDDEN { T t; @@ -81,6 +81,6 @@ static constexpr size_t NumericHash(T t) noexcept { } template <class T> -static constexpr T CombineHashes(T l, T r) noexcept { +static constexpr T CombineHashes(T l, T r) noexcept { return IntHash(l) ^ r; } diff --git a/util/digest/sequence.h b/util/digest/sequence.h index 712331007b..3329ac70c3 100644 --- a/util/digest/sequence.h +++ b/util/digest/sequence.h @@ -42,7 +42,7 @@ public: } template <typename ElementType> - auto operator()(const TArrayRef<ElementType>& data) const { + auto operator()(const TArrayRef<ElementType>& data) const { return TBase<ElementType>()(data); } }; diff --git a/util/digest/sequence_ut.cpp b/util/digest/sequence_ut.cpp index 87d6102ee5..369339f730 100644 --- a/util/digest/sequence_ut.cpp +++ b/util/digest/sequence_ut.cpp @@ -54,7 +54,7 @@ private: int arr[] = {1, 2, 3}; const size_t canonicalHash = static_cast<size_t>(ULL(3903918011533391876)); TContiguousHash<TSimpleRangeHash> hasher; - UNIT_ASSERT_EQUAL(canonicalHash, hasher(TArrayRef<int>(arr, arr + 3))); + UNIT_ASSERT_EQUAL(canonicalHash, hasher(TArrayRef<int>(arr, arr + 3))); } }; |