aboutsummaryrefslogtreecommitdiffstats
path: root/src/libserver/protocol.c
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2016-12-05 13:03:09 +0000
committerVsevolod Stakhov <vsevolod@highsecure.ru>2016-12-05 13:03:09 +0000
commitca6f7e1de911f557aea95996ee0de4a5e781d1b7 (patch)
tree2f9288428d739918015ecc7f84d3c87d4c8b9702 /src/libserver/protocol.c
parentcd01e044ae181a5dc22c8e7a7dca015bbeb03e55 (diff)
downloadrspamd-ca6f7e1de911f557aea95996ee0de4a5e781d1b7.tar.gz
rspamd-ca6f7e1de911f557aea95996ee0de4a5e781d1b7.zip
[Rework] Use hash tables for symbols options
Diffstat (limited to 'src/libserver/protocol.c')
-rw-r--r--src/libserver/protocol.c22
1 files changed, 13 insertions, 9 deletions
diff --git a/src/libserver/protocol.c b/src/libserver/protocol.c
index f33422dfe..ace286dbf 100644
--- a/src/libserver/protocol.c
+++ b/src/libserver/protocol.c
@@ -804,17 +804,21 @@ make_rewritten_subject (struct metric *metric, struct rspamd_task *task)
}
static ucl_object_t *
-rspamd_str_list_ucl (GList *str_list)
+rspamd_str_hash_ucl (GHashTable *ht)
{
+ GHashTableIter it;
+ gpointer k, v;
ucl_object_t *top = NULL, *obj;
- GList *cur;
top = ucl_object_typed_new (UCL_ARRAY);
- cur = str_list;
- while (cur) {
- obj = ucl_object_fromstring (cur->data);
- ucl_array_append (top, obj);
- cur = g_list_next (cur);
+
+ if (ht) {
+ g_hash_table_iter_init (&it, ht);
+
+ while (g_hash_table_iter_next (&it, &k, &v)) {
+ obj = ucl_object_fromstring ((const char *)v);
+ ucl_array_append (top, obj);
+ }
}
return top;
@@ -841,8 +845,8 @@ rspamd_metric_symbol_ucl (struct rspamd_task *task, struct metric *m,
description), "description", 0, false);
}
if (sym->options != NULL) {
- ucl_object_insert_key (obj, rspamd_str_list_ucl (
- sym->options), "options", 0, false);
+ ucl_object_insert_key (obj, rspamd_str_hash_ucl (sym->options),
+ "options", 0, false);
}
return obj;