diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2014-08-24 16:44:32 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2014-08-24 16:44:32 +0100 |
commit | e1659e40db3f5da8492bf75a3e270146ce6cca32 (patch) | |
tree | 9a60e806bb68b576268e5313af68aaeb6f0b9d8f | |
parent | 505a20a176f0acd4938aa54abe6307c7ec0f01c5 (diff) | |
download | rspamd-e1659e40db3f5da8492bf75a3e270146ce6cca32.tar.gz rspamd-e1659e40db3f5da8492bf75a3e270146ce6cca32.zip |
Use xxhash by default.
-rw-r--r-- | src/libutil/util.c | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/src/libutil/util.c b/src/libutil/util.c index 4562a90fe..3ca0c1aca 100644 --- a/src/libutil/util.c +++ b/src/libutil/util.c @@ -31,6 +31,8 @@ #include "filter.h" #include "message.h" +#include "xxhash.h" + #ifdef HAVE_OPENSSL #include <openssl/rand.h> #include <openssl/err.h> @@ -1149,24 +1151,25 @@ rspamd_strcase_hash (gconstpointer key) { const gchar *p = key; gchar buf[256]; - guint h = 0, i = 0; - + guint i = 0; + gpointer xxh; + xxh = XXH32_init (0); while (*p != '\0') { buf[i] = g_ascii_tolower (*p); i++; p++; if (i == sizeof (buf)) { - h ^= murmur32_hash (buf, i); + XXH32_update (xxh, buf, i); i = 0; } } if (i > 0) { - h ^= murmur32_hash (buf, i); + XXH32_update (xxh, buf, i); } - return h; + return XXH32_digest (xxh); } guint @@ -1176,7 +1179,7 @@ rspamd_str_hash (gconstpointer key) len = strlen ((const gchar *)key); - return murmur32_hash (key, len); + return XXH32 (key, len, 0); } gboolean @@ -1203,25 +1206,27 @@ fstr_strcase_hash (gconstpointer key) { const f_str_t *f = key; const gchar *p; - guint h = 0, i = 0; + guint i = 0; gchar buf[256]; + gpointer xxh; + xxh = XXH32_init (0); p = f->begin; while (p - f->begin < (gint)f->len) { buf[i] = g_ascii_tolower (*p); i++; p++; if (i == sizeof (buf)) { - h ^= murmur32_hash (buf, i); + XXH32_update (xxh, buf, i); i = 0; } } if (i > 0) { - h ^= murmur32_hash (buf, i); + XXH32_update (xxh, buf, i); } - return h; + return XXH32_digest (xxh); } void |