]> source.dussan.org Git - rspamd.git/commitdiff
[Feature] Try to select the optimal possible function for input
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Wed, 11 May 2016 15:28:07 +0000 (16:28 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Wed, 11 May 2016 15:28:07 +0000 (16:28 +0100)
src/libcryptobox/cryptobox.c

index 0617f8c21553148f1a325ace6173e35bb902cc87..d8fc737d78ac81611fb1bf3fb2d5008ba6a08972 100644 (file)
@@ -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);
 }