diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2015-04-14 13:11:28 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2015-04-14 13:11:28 +0100 |
commit | fa43e3bfc7a4ca93b3ffcae730b6705bc402a2b5 (patch) | |
tree | 9333e5182c927238eaca79c615cb36d7d08d1888 /src/libmime | |
parent | c4572edbf6d6bec6bb031479a9bcd0a3f1cd1bbe (diff) | |
download | rspamd-fa43e3bfc7a4ca93b3ffcae730b6705bc402a2b5.tar.gz rspamd-fa43e3bfc7a4ca93b3ffcae730b6705bc402a2b5.zip |
Use hash table instead of tree for urls.
Diffstat (limited to 'src/libmime')
-rw-r--r-- | src/libmime/message.c | 4 | ||||
-rw-r--r-- | src/libmime/mime_expressions.c | 13 |
2 files changed, 9 insertions, 8 deletions
diff --git a/src/libmime/message.c b/src/libmime/message.c index b94d2fb19..95a9bea95 100644 --- a/src/libmime/message.c +++ b/src/libmime/message.c @@ -1718,8 +1718,8 @@ process_message (struct rspamd_task *task) if ((rc == URI_ERRNO_OK) && subject_url->hostlen > 0) { if (subject_url->protocol != PROTOCOL_MAILTO) { - if (!g_tree_lookup (task->urls, subject_url)) { - g_tree_insert (task->urls, + if (!g_hash_table_lookup (task->urls, subject_url)) { + g_hash_table_insert (task->urls, subject_url, subject_url); } diff --git a/src/libmime/mime_expressions.c b/src/libmime/mime_expressions.c index afae67487..b4271f1dc 100644 --- a/src/libmime/mime_expressions.c +++ b/src/libmime/mime_expressions.c @@ -737,23 +737,24 @@ struct url_regexp_param { gboolean found; }; -static gboolean +static void tree_url_callback (gpointer key, gpointer value, void *data) { struct url_regexp_param *param = data; struct rspamd_url *url = value; + if (param->found) { + return; + } + if (rspamd_mime_regexp_element_process (param->task, param->re, struri (url), 0, FALSE)) { param->found = TRUE; - return TRUE; } else if (G_UNLIKELY (param->re->is_test)) { msg_info ("process test regexp %s for url %s returned FALSE", struri (url)); } - - return FALSE; } static gint @@ -911,10 +912,10 @@ rspamd_mime_expr_process_regexp (struct rspamd_regexp_atom *re, callback_param.re = re; callback_param.found = FALSE; if (task->urls) { - g_tree_foreach (task->urls, tree_url_callback, &callback_param); + g_hash_table_foreach (task->urls, tree_url_callback, &callback_param); } if (task->emails && callback_param.found == FALSE) { - g_tree_foreach (task->emails, tree_url_callback, &callback_param); + g_hash_table_foreach (task->emails, tree_url_callback, &callback_param); } if (callback_param.found == FALSE) { rspamd_task_re_cache_add (task, re->regexp_text, 0); |