From 6d584b10ec530c23bae4b894e9065ef765ccc6c9 Mon Sep 17 00:00:00 2001 From: Danny Robson Date: Sat, 23 Jan 2021 06:47:59 +1000 Subject: [PATCH] chunk/find: don't hard code the buzhash shift --- emory/chunk/find.hpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/emory/chunk/find.hpp b/emory/chunk/find.hpp index 64f4aaf..3e54762 100644 --- a/emory/chunk/find.hpp +++ b/emory/chunk/find.hpp @@ -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; }