From 5013550599d7d8e8b61572ecc9423218baad171d Mon Sep 17 00:00:00 2001 From: Helmut Grohne Date: Sun, 24 Mar 2013 17:21:53 +0100 Subject: update total_size as early as possible This improves the success rate of ssdeep_try_reduce_blockhash and thereby gives a significant speedup. --- fuzzy.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/fuzzy.c b/fuzzy.c index 83cf3ce..a6e238c 100644 --- a/fuzzy.c +++ b/fuzzy.c @@ -159,7 +159,7 @@ static void ssdeep_try_reduce_blockhash(struct ssdeep_context *self) { static const char *b64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; -static int ssdeep_engine_step(struct ssdeep_context *self, unsigned char c) { +static void ssdeep_engine_step(struct ssdeep_context *self, unsigned char c) { size_t h; unsigned int i; /* At each character we update the rolling hash and the normal hashes. @@ -203,15 +203,13 @@ static int ssdeep_engine_step(struct ssdeep_context *self, unsigned char c) { } else ssdeep_try_reduce_blockhash(self); } - ++self->total_size; - return 0; } static int ssdeep_engine(struct ssdeep_context *self, const unsigned char *buffer, size_t buffer_size) { + self->total_size += buffer_size; for( ;buffer_size > 0; ++buffer, --buffer_size) - if(ssdeep_engine_step(self, *buffer) < 0) - return -1; + ssdeep_engine_step(self, *buffer); return 0; } -- cgit v1.2.3