chunk/find: don't hard code the buzhash shift

This commit is contained in:
Danny Robson 2021-01-23 06:47:59 +10:00
parent 0028e5f382
commit 6d584b10ec

View File

@ -37,6 +37,7 @@ namespace emory::chunk {
digest_type const mask = ~digest_type (0) >> (sizeof (digest_type) * 8 - p.bits);
u64 hash_state = 0;
static u64 constexpr hash_shift = 1;
auto start = src.begin ();
// Scan the entire source memory region
@ -54,8 +55,8 @@ namespace emory::chunk {
if (cursor < start + p.maximum) {
// Rotate the buzhash state if we haven't hit a marker.
if (likely (hash_state & mask)) {
hash_state = cruft::rotatel (hash_state, 1)
^ cruft::rotatel (u64 (*(cursor - p.window)), p.window)
hash_state = cruft::rotatel (hash_state, hash_shift)
^ cruft::rotatel (u64 (*(cursor - p.window)), p.window * hash_shift)
^ *cursor;
continue;
}