hash function

Zach the Mystic reachBUTMINUSTHISzach at gOOGLYmail.com
Thu Feb 14 19:33:09 PST 2013


On Friday, 15 February 2013 at 02:26:31 UTC, Adam D. Ruppe wrote:
> druntime has a hash implementation in module rt.util.hash that 
> looks pretty useful, but isn't publicaly exported by the 
> library anywhere.
>
> Does phobos or druntime offer a public hash function like that? 
> If no, can it expose this one?

This might be a good time to bring up something that was 
bothering me when I examined the current druntime hash 
implementation. Just out of curiosity I was researching hash 
functions, and I found the hash function expert Bob Jenkins' FAQ 
about hashes:

http://burtleburtle.net/bob/hash/hashfaq.html

He says specifically that any hash function requiring a modulo 
prime at the end is bad (inefficient), but if I'm not mistaken, 
the druntime does just that. At line 50 of the associative array 
module there is a list of primes, and I believe the 
implementation assumes them to be necessary.

https://github.com/D-Programming-Language/druntime/blob/master/src/rt/aaA.d

I don't know enough to be sure this is a problem. There might be 
some other reason for the modulo prime, but I'd like to put my 
mind at ease on it.


More information about the Digitalmars-d mailing list