diff options
author | Vsevolod Stakhov <vsevolod@rspamd.com> | 2023-06-17 15:01:36 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@rspamd.com> | 2023-06-17 15:01:36 +0100 |
commit | c477b4b5252adb3150ec7dfb761383e3e619453c (patch) | |
tree | 95bdf89b796d339d418f869818e2814eebcbfcc4 /src | |
parent | 3eaac7242186440c3345052b85f94ad1cc41aeec (diff) | |
download | rspamd-c477b4b5252adb3150ec7dfb761383e3e619453c.tar.gz rspamd-c477b4b5252adb3150ec7dfb761383e3e619453c.zip |
[Minor] Define simple ftok hash and equal functions
Diffstat (limited to 'src')
-rw-r--r-- | src/libutil/str_util.c | 21 | ||||
-rw-r--r-- | src/libutil/str_util.h | 6 |
2 files changed, 3 insertions, 24 deletions
diff --git a/src/libutil/str_util.c b/src/libutil/str_util.c index 86369909a..dc45cba45 100644 --- a/src/libutil/str_util.c +++ b/src/libutil/str_util.c @@ -333,27 +333,6 @@ rspamd_ftok_icase_hash (gconstpointer key) } 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) { const GString *f1 = v, *f2 = v2; diff --git a/src/libutil/str_util.h b/src/libutil/str_util.h index 199a384ca..c0b9c1323 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); |