]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib: event filter - Extend existing queries if context matches (event_filter_merge_wi...
authorJosef 'Jeff' Sipek <jeff.sipek@open-xchange.com>
Wed, 21 Apr 2021 15:47:51 +0000 (11:47 -0400)
committerjeff.sipek <jeff.sipek@open-xchange.com>
Tue, 27 Apr 2021 17:46:14 +0000 (17:46 +0000)
Since there is no practical difference between a filter with one query and a
filter with multiple queries using the same context pointer, we can extend
the existing queries as long as there is a context pointer match.  This
reduces the number of queries (and filter expressions) thereby increasing
future optimization opportunities.

src/lib/event-filter.c

index f232db88acc3b6e8595d8a2835631b0c5108a7de..7285cecaaede791c27846b569340f8ed9766d5fd 100644 (file)
@@ -355,11 +355,14 @@ event_filter_merge_with_context_internal(struct event_filter *dest,
        const struct event_filter_query_internal *int_query;
 
        array_foreach(&src->queries, int_query) T_BEGIN {
+               void *context = with_context ? new_context : int_query->context;
                struct event_filter_query_internal *new;
 
-               new = array_append_space(&dest->queries);
-               new->expr = clone_expr(dest->pool, int_query->expr);
-               new->context = with_context ? new_context : int_query->context;
+               new = event_filter_get_or_alloc_internal_query(dest, context);
+
+               add_node(dest->pool, &new->expr,
+                        clone_expr(dest->pool, int_query->expr),
+                        EVENT_FILTER_OP_OR);
        } T_END;
 }