mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-06 15:48:51 +00:00
Simplification to ptr_map_hash_key
This commit is contained in:
+5
-15
@@ -28,21 +28,11 @@ struct PtrMap {
|
|||||||
|
|
||||||
u32 ptr_map_hash_key(uintptr key) {
|
u32 ptr_map_hash_key(uintptr key) {
|
||||||
#if defined(GB_ARCH_64_BIT)
|
#if defined(GB_ARCH_64_BIT)
|
||||||
// TODO(bill): Improve ptr_map_hash_key
|
u64 x = (u64)key;
|
||||||
u32 key0 = (u32)(key & 0xffffffff);
|
u8 count = (u8)(x >> 59);
|
||||||
u32 key1 = (u32)(key >> 32);
|
x ^= x >> (5 + count);
|
||||||
|
x *= 12605985483714917081ull;
|
||||||
u32 word;
|
return (u32)(x ^ (x >> 43));
|
||||||
u32 state = 0;
|
|
||||||
|
|
||||||
state += key0 * 747796405u + 2891336453u;
|
|
||||||
word = ((state >> ((state >> 28u) + 4u)) ^ state) * 277803737u;
|
|
||||||
state = (word >> 22u) ^ word;
|
|
||||||
state += key1 * 747796405u + 2891336453u;
|
|
||||||
word = ((state >> ((state >> 28u) + 4u)) ^ state) * 277803737u;
|
|
||||||
state = (word >> 22u) ^ word;
|
|
||||||
return state;
|
|
||||||
|
|
||||||
#elif defined(GB_ARCH_32_BIT)
|
#elif defined(GB_ARCH_32_BIT)
|
||||||
u32 state = ((u32)key) * 747796405u + 2891336453u;
|
u32 state = ((u32)key) * 747796405u + 2891336453u;
|
||||||
u32 word = ((state >> ((state >> 28u) + 4u)) ^ state) * 277803737u;
|
u32 word = ((state >> ((state >> 28u) + 4u)) ^ state) * 277803737u;
|
||||||
|
|||||||
Reference in New Issue
Block a user