aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/digest/sfh
diff options
context:
space:
mode:
authormonster <monster@yandex-team.ru>2022-02-10 16:47:19 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:47:19 +0300
commitb23c1d7a8015c2006a148fd93b84cdeb0aee17a3 (patch)
tree9814fbd1c3effac9b8377c5d604b367b14e2db55 /library/cpp/digest/sfh
parentdd76ae1f6213d065375ab296699f764faafbe5bd (diff)
downloadydb-b23c1d7a8015c2006a148fd93b84cdeb0aee17a3.tar.gz
Restoring authorship annotation for <monster@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'library/cpp/digest/sfh')
-rw-r--r--library/cpp/digest/sfh/sfh.h52
1 files changed, 26 insertions, 26 deletions
diff --git a/library/cpp/digest/sfh/sfh.h b/library/cpp/digest/sfh/sfh.h
index 6535013201..372938654c 100644
--- a/library/cpp/digest/sfh/sfh.h
+++ b/library/cpp/digest/sfh/sfh.h
@@ -1,51 +1,51 @@
#pragma once
-
+
#include <util/system/defaults.h>
#include <util/system/unaligned_mem.h>
-
+
inline ui32 SuperFastHash(const void* d, size_t l) noexcept {
ui32 hash = (ui32)l;
ui32 tmp;
if (!l || !d)
return 0;
-
+
TUnalignedMemoryIterator<ui16, 4> iter(d, l);
-
+
while (!iter.AtEnd()) {
hash += (ui32)iter.Next();
tmp = ((ui32)iter.Next() << 11) ^ hash;
hash = (hash << 16) ^ tmp;
hash += hash >> 11;
- }
-
+ }
+
switch (iter.Left()) {
case 3:
hash += (ui32)iter.Next();
- hash ^= hash << 16;
+ hash ^= hash << 16;
hash ^= ((ui32)(i32) * (const i8*)iter.Last()) << 18;
- hash += hash >> 11;
- break;
+ hash += hash >> 11;
+ break;
case 2:
hash += (ui32)iter.Cur();
- hash ^= hash << 11;
- hash += hash >> 17;
- break;
+ hash ^= hash << 11;
+ hash += hash >> 17;
+ break;
case 1:
hash += *((const i8*)iter.Last());
- hash ^= hash << 10;
- hash += hash >> 1;
- }
-
- /* Force "avalanching" of final 127 bits */
- hash ^= hash << 3;
- hash += hash >> 5;
- hash ^= hash << 4;
- hash += hash >> 17;
- hash ^= hash << 25;
- hash += hash >> 6;
-
- return hash;
-}
+ hash ^= hash << 10;
+ hash += hash >> 1;
+ }
+
+ /* Force "avalanching" of final 127 bits */
+ hash ^= hash << 3;
+ hash += hash >> 5;
+ hash ^= hash << 4;
+ hash += hash >> 17;
+ hash ^= hash << 25;
+ hash += hash >> 6;
+
+ return hash;
+}