summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPeter Pentchev <roam@ringlet.net>2022-07-07 08:53:57 +0300
committerPeter Pentchev <roam@ringlet.net>2022-07-07 08:53:57 +0300
commitded97628f79aa3517329f8a0831cca780c3391f5 (patch)
tree0c35a4f6256fbfca50c4c66a14fbf2c478126be3 /src
parent085973a486d2a394385e5c3575ca8c2f9c3cc99b (diff)
murmurhash: always load byte by byte
Also reverse the order of bytes, loading the most significant parts first, and use bitwise "or" instead of addition.
Diffstat (limited to 'src')
-rw-r--r--src/hash.cc6
1 files changed, 1 insertions, 5 deletions
diff --git a/src/hash.cc b/src/hash.cc
index a603e48b..3fad8f42 100644
--- a/src/hash.cc
+++ b/src/hash.cc
@@ -41,11 +41,7 @@ size_t hash_data(const char* input, size_t len)
for (ptrdiff_t i = -nblocks; i; ++i)
{
uint32_t key;
-#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
- memcpy(&key, blocks + 4*i, 4);
-#else
- key = blocks[4*i] + (blocks[4*i + 1] << 8) + (blocks[4*i + 2] << 16) + (blocks[4*i + 3] << 24);
-#endif
+ key = (blocks[4*i + 3] << 24) | (blocks[4*i + 2] << 16) | (blocks[4*i + 1] << 8) + blocks[4*i];
key *= c1;
key = rotl(key, 15);
key *= c2;