1
0
forked from Mirror/wren

Fix horrendously bad bit hashing function.

hashBits() is used to generate a hash code from the same 64 bits used
to represent a Wren number as a double. When building a map containing
a large number of integer keys, it's important for this to do a good
job scattering the bits across the 32-bit key space.

Alas, it does not. Worse, the benchmark to test this happens to stop
just before the performance falls off a cliff, so this was easy to
overlook.

This replaces it with the hash function V8 uses, which has much better
performance across the numeric range.
This commit is contained in:
Robert Nystrom
2019-07-27 13:34:07 -07:00
parent d1a0d0682a
commit 2a1499b04b
7 changed files with 29 additions and 37 deletions

View File

@ -86,7 +86,7 @@ BENCHMARK("for", r"""499999500000""")
BENCHMARK("method_call", r"""true
false""")
BENCHMARK("map_numeric", r"""500000500000""")
BENCHMARK("map_numeric", r"""2000001000000""")
BENCHMARK("map_string", r"""12799920000""")