dedup

deduplicating backup program
git clone git://git.2f30.org/dedup
Log | Files | Refs | README | LICENSE

commit e8031b23797e666b43f96906372d97e2da4f4d0a
parent 51e30cc320f67d76423856e7f0fc790431f9cf5f
Author: sin <sin@2f30.org>
Date:   Fri, 22 Feb 2019 11:20:51 +0000

Simplify hash a bit

Diffstat:
Mhash.c | 15++++++---------
1 file changed, 6 insertions(+), 9 deletions(-)

diff --git a/hash.c b/hash.c @@ -49,22 +49,19 @@ static uint32_t buz[] = { /* Buzhash: https://en.wikipedia.org/wiki/Rolling_hash#Cyclic_polynomial */ uint32_t -buzh_init(uint8_t *buf, size_t size) +buzh_init(uint8_t *buf, size_t winsize) { - size_t i; uint32_t fp; + size_t i; - if (!size) - return 0; - - for (i = size - 1, fp = 0; i > 0; i--, buf++) - fp ^= ROTL(buz[*buf], i % 32); + for (i = 1, fp = 0; i < winsize; i++, buf++) + fp ^= ROTL(buz[*buf], (winsize - i) % 32); return fp ^ buz[*buf]; } uint32_t -buzh_update(uint32_t fp, uint8_t in, uint8_t out, size_t size) +buzh_update(uint32_t fp, uint8_t in, uint8_t out, size_t winsize) { - return ROTL(fp, 1) ^ ROTL(buz[out], size % 32) ^ buz[in]; + return ROTL(fp, 1) ^ ROTL(buz[out], winsize % 32) ^ buz[in]; }