druntime icon indicating copy to clipboard operation
druntime copied to clipboard

core.internal.hash.bytesHash: in 64-bit builds use a 64-bit-oriented algorithm

Open n8sh opened this issue 5 years ago • 4 comments

Motivation: doesn't discard high 32 bits of seed; produces 64 bits of output; and is a bit faster.

n8sh avatar Jul 02 '20 00:07 n8sh

Thanks for your pull request, @n8sh!

Bugzilla references

Auto-close Bugzilla Severity Description
21006 enhancement core.internal.hash.bytesHash: in 64-bit builds use a 64-bit-oriented algorithm

Testing this PR locally

If you don't have a local development environment setup, you can use Digger to test this PR:

dub run digger -- build "master + druntime#3148"

dlang-bot avatar Jul 02 '20 00:07 dlang-bot

Test runnable/testaa2.d failed: 
expected:
----
foo()
foo() 2
foo() 3
foo() 4
c["foo"] = 3
c["bar"] = 4
Success
----
actual:
----
foo()
foo() 2
foo() 3
foo() 4
c["bar"] = 4
c["foo"] = 3
Success

A DMD test is failing because it depends on a specific AA traversal order. I am inclined to consider that erroneous based on https://dlang.org/spec/hash-map.html:

The built-in associative arrays do not preserve the order of the keys inserted into the array. In particular, in a foreach loop the order in which the elements are iterated is typically unspecified.

n8sh avatar Jul 02 '20 01:07 n8sh

Indeed. This test should be fixed.

Geod24 avatar Jul 02 '20 01:07 Geod24

Please add a reference for this hash algorithm in a comment

MoonlightSentinel avatar Aug 02 '20 18:08 MoonlightSentinel