diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2016-05-12 09:48:29 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2016-05-12 09:48:29 +0100 |
commit | 931615a2e0c1069c161bf2c9516732f576f20ee3 (patch) | |
tree | 9a195f6cc8da39dcc64eb8984189589e5a974f10 /src/libcryptobox | |
parent | 25db12ee3fce3a41c1fd907373ead67015cef6ed (diff) | |
download | rspamd-931615a2e0c1069c161bf2c9516732f576f20ee3.tar.gz rspamd-931615a2e0c1069c161bf2c9516732f576f20ee3.zip |
[Feature] Further micro-optimizations for hashing and shingles
Diffstat (limited to 'src/libcryptobox')
-rw-r--r-- | src/libcryptobox/cryptobox.c | 13 | ||||
-rw-r--r-- | src/libcryptobox/cryptobox.h | 3 |
2 files changed, 8 insertions, 8 deletions
diff --git a/src/libcryptobox/cryptobox.c b/src/libcryptobox/cryptobox.c index d8fc737d7..162fcd662 100644 --- a/src/libcryptobox/cryptobox.c +++ b/src/libcryptobox/cryptobox.c @@ -1459,20 +1459,17 @@ guint64 rspamd_cryptobox_fast_hash (const void *data, gsize len, guint64 seed) { - if (len % 2 == 0) { + if (len > 8 && len % 8 == 0) { return rspamd_cryptobox_fast_hash_specific (RSPAMD_CRYPTOBOX_MUMHASH, data, len, seed); } else { #if defined(__LP64__) || defined(_LP64) - if (len > 8) { - return rspamd_cryptobox_fast_hash_specific (RSPAMD_CRYPTOBOX_XXHASH64, - data, len, seed); - } + return rspamd_cryptobox_fast_hash_specific (RSPAMD_CRYPTOBOX_XXHASH64, + data, len, seed); #endif } - return rspamd_cryptobox_fast_hash_specific (RSPAMD_CRYPTOBOX_XXHASH32, data, len, seed); } @@ -1490,7 +1487,9 @@ rspamd_cryptobox_fast_hash_specific ( case RSPAMD_CRYPTOBOX_XXHASH64: return XXH64 (data, len, seed); case RSPAMD_CRYPTOBOX_MUMHASH: - default: return mum_hash (data, len, seed); + case RSPAMD_CRYPTOBOX_HASHFAST: + default: + return rspamd_cryptobox_fast_hash (data, len, seed); } } diff --git a/src/libcryptobox/cryptobox.h b/src/libcryptobox/cryptobox.h index 18e66df60..c44044f48 100644 --- a/src/libcryptobox/cryptobox.h +++ b/src/libcryptobox/cryptobox.h @@ -357,7 +357,8 @@ guint64 rspamd_cryptobox_fast_hash (const void *data, enum rspamd_cryptobox_fast_hash_type { RSPAMD_CRYPTOBOX_XXHASH64 = 0, RSPAMD_CRYPTOBOX_XXHASH32, - RSPAMD_CRYPTOBOX_MUMHASH + RSPAMD_CRYPTOBOX_MUMHASH, + RSPAMD_CRYPTOBOX_HASHFAST }; /** * Platform independent version |