Open blinkinglight opened 5 years ago
http://www.cse.yorku.ca/~oz/hash.html
this algorithm (k=33) was first reported by dan bernstein many years ago in comp.lang.c. another version of this algorithm (now favored by bernstein) uses xor: hash(i) = hash(i - 1) * 33 ^ str[i]; the magic of number 33 (why it works better than many other constants, prime or not) has never been adequately explained.
https://github.com/patrickmn/go-cache/blob/5633e0862627c011927fa39556acae8b1f1df58a/sharded.go#L40
can you benchmark this?