mirror of
https://github.com/janet-lang/janet
synced 2024-11-29 03:19:54 +00:00
More improvements to hashing for #889
This commit is contained in:
parent
e8ad311d84
commit
f9891a5c04
@ -225,7 +225,8 @@ int32_t janet_string_calchash(const uint8_t *str, int32_t len) {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
uint32_t janet_hash_mix(uint32_t input, uint32_t more) {
|
uint32_t janet_hash_mix(uint32_t input, uint32_t more) {
|
||||||
return input ^ ((more * 2119589369u) + 0x9e3779b9 + (input << 6) + (input >> 2));
|
uint32_t mix1 = (more + 0x9e3779b9 + (input << 6) + (input >> 2));
|
||||||
|
return input ^ (0x9e3779b9 + (mix1 << 6) + (mix1 >> 2));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Computes hash of an array of values */
|
/* Computes hash of an array of values */
|
||||||
|
@ -324,7 +324,7 @@ 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));
|
hash = (int32_t)((hi ^ (lo >> 3)) * 2654435769u);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case JANET_ABSTRACT: {
|
case JANET_ABSTRACT: {
|
||||||
|
Loading…
Reference in New Issue
Block a user