@@ -22,12 +22,6 @@ static inline uint64_t chibihash64__rotl(uint64_t x, int n)
2222{
2323 return (x << n ) | (x >> (- n & 63 ));
2424}
25- static inline uint64_t chibihash64__reduce (uint64_t a , uint64_t b )
26- {
27- uint64_t x = a * (chibihash64__rotl (b , 9 ) | 1 );
28- x ^= chibihash64__rotl (b , 41 ) + chibihash64__rotl (a , 31 );
29- return x ;
30- }
3125
3226static inline uint64_t
3327chibihash64 (const void * keyIn , ptrdiff_t len , uint64_t seed )
@@ -68,15 +62,19 @@ chibihash64(const void *keyIn, ptrdiff_t len, uint64_t seed)
6862 h [3 ] ^= p [l /2 ] | ((uint64_t )p [l - 1 ] << 8 );
6963 }
7064
65+ h [0 ] += chibihash64__rotl (h [2 ] * K , 31 ) ^ (h [2 ] >> 31 );
66+ h [1 ] += chibihash64__rotl (h [3 ] * K , 31 ) ^ (h [3 ] >> 31 );
67+ h [0 ] *= K ; h [0 ] ^= h [0 ] >> 31 ;
68+ h [1 ] += h [0 ];
69+
7170 uint64_t x = (uint64_t )len * K ;
7271 x ^= chibihash64__rotl (x , 29 );
73- x ^= chibihash64__reduce ( h [ 0 ], h [ 1 ]) ;
74- x ^= chibihash64__reduce ( h [ 2 ], h [ 3 ]) + seed ;
72+ x += seed ;
73+ x ^= h [ 1 ] ;
7574
76- // moremur: https://mostlymangling.blogspot.com/2019/12/stronger-better-morer-moremur-better.html
77- x ^= x >> 27 ; x *= UINT64_C (0x3C79AC492BA7B653 );
78- x ^= x >> 33 ; x *= UINT64_C (0x1C69B3F74AC4AE35 );
79- x ^= x >> 27 ;
75+ x ^= chibihash64__rotl (x , 15 ) ^ chibihash64__rotl (x , 42 );
76+ x *= K ;
77+ x ^= chibihash64__rotl (x , 13 ) ^ chibihash64__rotl (x , 31 );
8078
8179 return x ;
8280}
0 commit comments