diff --git a/src/json_obj.c b/src/json_obj.c index 3928ec4..55cdeb9 100644 --- a/src/json_obj.c +++ b/src/json_obj.c @@ -12,19 +12,19 @@ djb2 string hash credits: Daniel J. Bernstein - Returns a hash of the string `str`. + Returns a hash of the string `str`. - It seems to work well because 33 is coprime to - 2^32 and 2^64 (any odd number except 1 is), - which probably improves the distribution - (I'm not a mathematician so I can't prove it this). - Multiplying a number n by 33 is the same as - bitshifting by 5 and adding n, which is faster - than multiplying by, say, 37. Maybe any 2^x±1 - are equally good. + It seems to work well because 33 is coprime to + 2^32 and 2^64 (any odd number except 1 is), + which probably improves the distribution (I'm + not a mathematician so I can't prove it this). + Multiplying a number n by 33 is the same as + bitshifting by 5 and adding n, which is faster + than multiplying by, say, 37. Maybe any 2^x±1 + are equally good. - 5381 is a large-ish prime number which are used - as multipliers in most hash algorithms. + 5381 is a large-ish prime number which are used + as multipliers in most hash algorithms. */ size_t obj_hash(char const* str) {