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.
This commit is contained in:
parent
085973a486
commit
ded97628f7
|
@ -41,11 +41,7 @@ size_t hash_data(const char* input, size_t len)
|
||||||
for (ptrdiff_t i = -nblocks; i; ++i)
|
for (ptrdiff_t i = -nblocks; i; ++i)
|
||||||
{
|
{
|
||||||
uint32_t key;
|
uint32_t key;
|
||||||
#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
|
key = (blocks[4*i + 3] << 24) | (blocks[4*i + 2] << 16) | (blocks[4*i + 1] << 8) + blocks[4*i];
|
||||||
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 *= c1;
|
key *= c1;
|
||||||
key = rotl(key, 15);
|
key = rotl(key, 15);
|
||||||
key *= c2;
|
key *= c2;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user