From 8105992157606e77f0e88968a40aaf8e528c70d8 Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Wed, 11 May 2016 16:28:07 +0100 Subject: [PATCH] [Feature] Try to select the optimal possible function for input --- src/libcryptobox/cryptobox.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/libcryptobox/cryptobox.c b/src/libcryptobox/cryptobox.c index 0617f8c21..d8fc737d7 100644 --- a/src/libcryptobox/cryptobox.c +++ b/src/libcryptobox/cryptobox.c @@ -1459,7 +1459,21 @@ guint64 rspamd_cryptobox_fast_hash (const void *data, gsize len, guint64 seed) { - return rspamd_cryptobox_fast_hash_specific (RSPAMD_CRYPTOBOX_MUMHASH, + if (len % 2 == 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); + } +#endif + } + + + return rspamd_cryptobox_fast_hash_specific (RSPAMD_CRYPTOBOX_XXHASH32, data, len, seed); } -- 2.39.5