From: Vsevolod Stakhov Date: Sat, 17 Jun 2023 14:01:36 +0000 (+0100) Subject: [Minor] Define simple ftok hash and equal functions X-Git-Tag: 3.6~68 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c477b4b5252adb3150ec7dfb761383e3e619453c;p=thirdparty%2Frspamd.git [Minor] Define simple ftok hash and equal functions --- diff --git a/src/libutil/str_util.c b/src/libutil/str_util.c index 86369909ad..dc45cba45e 100644 --- a/src/libutil/str_util.c +++ b/src/libutil/str_util.c @@ -332,27 +332,6 @@ rspamd_ftok_icase_hash (gconstpointer key) return (guint)rspamd_icase_hash (f->begin, f->len, rspamd_hash_seed ()); } -gboolean -rspamd_ftok_equal (gconstpointer v, gconstpointer v2) -{ - const rspamd_ftok_t *f1 = v, *f2 = v2; - - if (f1->len == f2->len && - memcmp (f1->begin, f2->begin, f1->len) == 0) { - return TRUE; - } - - return FALSE; -} - -guint -rspamd_ftok_hash (gconstpointer key) -{ - const rspamd_ftok_t *f = key; - - return (guint)rspamd_cryptobox_fast_hash (f->begin, f->len, rspamd_hash_seed ()); -} - gboolean rspamd_gstring_icase_equal (gconstpointer v, gconstpointer v2) { diff --git a/src/libutil/str_util.h b/src/libutil/str_util.h index 199a384cac..c0b9c1323d 100644 --- a/src/libutil/str_util.h +++ b/src/libutil/str_util.h @@ -80,9 +80,9 @@ guint rspamd_ftok_icase_hash (gconstpointer key); gboolean rspamd_ftok_icase_equal (gconstpointer v, gconstpointer v2); -guint rspamd_ftok_hash (gconstpointer key); - -gboolean rspamd_ftok_equal (gconstpointer v, gconstpointer v2); +/* Use in khash for speed */ +#define rspamd_ftok_hash(key) _wyhash32((key)->begin, (key)->len, 0) +#define rspamd_ftok_equal(v1, v2) ((v1)->len == (v2)->len && memcmp((v1)->begin, (v2)->begin, (v1)->len) == 0) guint rspamd_gstring_icase_hash (gconstpointer key);