equal hash code: avoid dropping useful bits
Closes PR 14059 Symbols in the PR were mapped to coliding hashes in groups of 4 because the low 2 bits of the `eq?` hash code were begin dropped to generate an `equal?` hash code. Those two bits got lost due to a refectoring a while back that moved the dropping of two useless bits to a more centralized place, but the 2-bit shift did not get removed from the `equal` hash code comparision. The PR's example program will still generate groups of 2 when hashing around 10k symbols (which used to be groups of 8). That's because there's a bit in the hash-code counter that turns out to be forced to 1.
This commit is contained in:
parent
8ff0193ebe
commit
8b7b96215b
|
@ -1371,7 +1371,7 @@ static uintptr_t equal_hash_key(Scheme_Object *o, uintptr_t k, Hash_Info *hi)
|
|||
|
||||
return k;
|
||||
} else
|
||||
return k + (PTR_TO_LONG(o) >> 2);
|
||||
return k + PTR_TO_LONG(o);
|
||||
}
|
||||
}
|
||||
case scheme_box_type:
|
||||
|
@ -1496,7 +1496,7 @@ static uintptr_t equal_hash_key(Scheme_Object *o, uintptr_t k, Hash_Info *hi)
|
|||
|
||||
return k + (MZ_OPT_HASH_KEY(&s->iso) & 0xFFFC);
|
||||
} else
|
||||
return k + (PTR_TO_LONG(o) >> 2);
|
||||
return k + PTR_TO_LONG(o);
|
||||
}
|
||||
# endif
|
||||
case scheme_resolved_module_path_type:
|
||||
|
@ -1532,7 +1532,7 @@ static uintptr_t equal_hash_key(Scheme_Object *o, uintptr_t k, Hash_Info *hi)
|
|||
if (h1)
|
||||
return h1(o, k, hi);
|
||||
else
|
||||
return k + (PTR_TO_LONG(o) >> 2);
|
||||
return k + PTR_TO_LONG(o);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user