mirror of
https://github.com/janet-lang/janet
synced 2024-11-05 08:16:16 +00:00
Address #889 - Switch high and low bits of part of number hash (Knuth's multiplicative hash)
Also make sure we weren't throwing away 3 bits of entropy.
This commit is contained in:
parent
1c937ad960
commit
92fdd07ca3
@ -324,7 +324,8 @@ int32_t janet_hash(Janet x) {
|
|||||||
as.d = janet_unwrap_number(x);
|
as.d = janet_unwrap_number(x);
|
||||||
uint32_t lo = (uint32_t)(as.u & 0xFFFFFFFF);
|
uint32_t lo = (uint32_t)(as.u & 0xFFFFFFFF);
|
||||||
uint32_t hi = (uint32_t)(as.u >> 32);
|
uint32_t hi = (uint32_t)(as.u >> 32);
|
||||||
hash = (int32_t)((hi ^ (lo >> 3)) * 2654435769u);
|
uint32_t hilo = (hi ^ lo) * 2654435769u;
|
||||||
|
hash = (int32_t)((hilo << 16) | ((hilo >> 16) & 0xFFFF));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case JANET_ABSTRACT: {
|
case JANET_ABSTRACT: {
|
||||||
|
Loading…
Reference in New Issue
Block a user