Commit 2241d15d authored by Geoff Simmons's avatar Geoff Simmons

Simplify expression of the PH hash function.

parent 52e204f6
...@@ -104,12 +104,12 @@ hash(const struct hash * const restrict hash, ...@@ -104,12 +104,12 @@ hash(const struct hash * const restrict hash,
assert((len >> 2) <= hash->l); assert((len >> 2) <= hash->l);
for (e = s + l; s < e; k += 2, s += 2) for (e = s + l; s < e; k += 2, s += 2)
h += (*s + *k) * (*(s+1) + *(k+1)); h += (s[0] + k[0]) * (s[1] + k[1]);
/* When the subject length is not an exact multiple of 8. */ /* When the subject length is not an exact multiple of 8. */
if ((len & 0x07) != 0) { if ((len & 0x07) != 0) {
memcpy(tail, e, (void *)(subject + len) - (void *)e); memcpy(tail, e, (void *)(subject + len) - (void *)e);
h += (*tail + *k) * (*(tail+1) + *(k+1)); h += (tail[0] + k[0]) * (tail[1] + k[1]);
} }
return ((h >> 32) & hash->mask); return ((h >> 32) & hash->mask);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment