changed hcl_hash_bytes() to sdbm hash
This commit is contained in:
parent
2b14218a43
commit
d75b34126e
@ -41,7 +41,13 @@ hcl_oow_t hcl_hash_bytes (const hcl_oob_t* ptr, hcl_oow_t len)
|
|||||||
const hcl_uint8_t* bp, * be;
|
const hcl_uint8_t* bp, * be;
|
||||||
|
|
||||||
bp = ptr; be = bp + len;
|
bp = ptr; be = bp + len;
|
||||||
while (bp < be) h = h * 31 + *bp++;
|
|
||||||
|
/* this hash doesn't produce good distribution */
|
||||||
|
/*while (bp < be) h = h * 31 + *bp++; */
|
||||||
|
|
||||||
|
/* SDBM hash is known to produce good overall distribution
|
||||||
|
* for many different data sets */
|
||||||
|
while (bp < be) h = (h << 6) + (h << 16) - h + *bp++;
|
||||||
|
|
||||||
/* constrain the hash value to be representable in a small integer
|
/* constrain the hash value to be representable in a small integer
|
||||||
* for convenience sake */
|
* for convenience sake */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user