diff options
author | Helmut Grohne <helmut@subdivi.de> | 2013-03-24 17:21:53 +0100 |
---|---|---|
committer | Helmut Grohne <helmut@subdivi.de> | 2013-03-24 17:21:53 +0100 |
commit | 5013550599d7d8e8b61572ecc9423218baad171d (patch) | |
tree | 75b91f52ea1b749973e5b2d8dea65195d6bc71f9 | |
parent | 4bcfb358f9c4e12a6cb4e1f519916006050898a8 (diff) | |
download | ssdeep-5013550599d7d8e8b61572ecc9423218baad171d.tar.gz |
update total_size as early as possible
This improves the success rate of ssdeep_try_reduce_blockhash and
thereby gives a significant speedup.
-rw-r--r-- | fuzzy.c | 8 |
1 files changed, 3 insertions, 5 deletions
@@ -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; } |