getHash inconsistency

Daniel Murphy yebblies at nospamgmail.com
Tue Mar 20 22:35:11 PDT 2012


"H. S. Teoh" <hsteoh at quickfur.ath.cx> wrote in message 
news:mailman.951.1332306541.4860.digitalmars-d at puremagic.com...
>
> Here's the current hashing code for char[] and string:
>
>        foreach (char c; s)
>            hash = hash * 11 + c;
>
> For const(char)[], it's rt.util.hash.hashOf, which is Paul Hsieh's
> SuperFastHash algorithm with very good hash distribution properties. It
> does seem to involve a lot more operations that the simple loop above,
> though; so I assume the above simple loop was chosen because hashing
> strings are a very common operation and, for the most part, only need a
> simple hash function.
>
> So I'm kinda leaning towards SuperFastHash, but worried about whether it
> will cause performance degradation, in which case we should stick with
> the simple loop.
>
>
> T
>
> -- 
> "Maybe" is a strange word.  When mom or dad says it it means "yes", but 
> when my big brothers say it it means "no"! -- PJ jr.

Benchmark time! 




More information about the Digitalmars-d mailing list