aboutsummaryrefslogtreecommitdiffstats
path: root/util/digest/fnv.h
diff options
context:
space:
mode:
authorAnton Samokhvalov <pg83@yandex.ru>2022-02-10 16:45:15 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:45:15 +0300
commit72cb13b4aff9bc9cf22e49251bc8fd143f82538f (patch)
treeda2c34829458c7d4e74bdfbdf85dff449e9e7fb8 /util/digest/fnv.h
parent778e51ba091dc39e7b7fcab2b9cf4dbedfb6f2b5 (diff)
downloadydb-72cb13b4aff9bc9cf22e49251bc8fd143f82538f.tar.gz
Restoring authorship annotation for Anton Samokhvalov <pg83@yandex.ru>. Commit 1 of 2.
Diffstat (limited to 'util/digest/fnv.h')
-rw-r--r--util/digest/fnv.h108
1 files changed, 54 insertions, 54 deletions
diff --git a/util/digest/fnv.h b/util/digest/fnv.h
index 87b41a3de7..e4aa6d3fb8 100644
--- a/util/digest/fnv.h
+++ b/util/digest/fnv.h
@@ -2,70 +2,70 @@
#include <util/system/defaults.h>
-#define FNV32INIT 2166136261U
+#define FNV32INIT 2166136261U
#define FNV32PRIME 16777619U
-#define FNV64INIT ULL(14695981039346656037)
+#define FNV64INIT ULL(14695981039346656037)
#define FNV64PRIME ULL(1099511628211)
-namespace NFnvPrivate {
- template <class It>
+namespace NFnvPrivate {
+ template <class It>
constexpr ui32 FnvHash32(It b, It e, ui32 init) {
- while (b != e) {
- init = (init * FNV32PRIME) ^ (unsigned char)*b++;
- }
-
- return init;
- }
-
- template <class It>
+ while (b != e) {
+ init = (init * FNV32PRIME) ^ (unsigned char)*b++;
+ }
+
+ return init;
+ }
+
+ template <class It>
constexpr ui64 FnvHash64(It b, It e, ui64 init) {
- while (b != e) {
- init = (init * FNV64PRIME) ^ (unsigned char)*b++;
- }
-
- return init;
- }
-
- template <unsigned N>
- struct TFnvHelper;
-
-#define DEF_FNV(t) \
- template <> \
- struct TFnvHelper<t> { \
- static const ui##t Init = FNV##t##INIT; \
- template <class It> \
+ while (b != e) {
+ init = (init * FNV64PRIME) ^ (unsigned char)*b++;
+ }
+
+ return init;
+ }
+
+ template <unsigned N>
+ struct TFnvHelper;
+
+#define DEF_FNV(t) \
+ template <> \
+ 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) { \
- return FnvHash##t(b, e, init); \
- } \
- };
-
- DEF_FNV(32)
- DEF_FNV(64)
-
-#undef DEF_FNV
-}
-
-template <class T, class It>
+ return FnvHash##t(b, e, init); \
+ } \
+ };
+
+ DEF_FNV(32)
+ DEF_FNV(64)
+
+#undef DEF_FNV
+}
+
+template <class T, class It>
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_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) {
- return FnvHash<T>(b, e, (T)NFnvPrivate::TFnvHelper<8 * sizeof(T)>::Init);
-}
-
-template <class T>
+ 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) {
- return FnvHash<T>((const unsigned char*)buf, (const unsigned char*)buf + len, init);
-}
-
-template <class T>
+ 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) {
- return FnvHash<T>((const unsigned char*)buf, (const unsigned char*)buf + 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) {