From: Josef 'Jeff' Sipek Date: Wed, 21 Apr 2021 15:47:51 +0000 (-0400) Subject: lib: event filter - Extend existing queries if context matches (event_filter_merge_wi... X-Git-Tag: 2.3.16~311 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=12507668f7534590473db05867316b6e6ae5ea5e;p=thirdparty%2Fdovecot%2Fcore.git lib: event filter - Extend existing queries if context matches (event_filter_merge_with_context*) 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. --- diff --git a/src/lib/event-filter.c b/src/lib/event-filter.c index f232db88ac..7285cecaae 100644 --- a/src/lib/event-filter.c +++ b/src/lib/event-filter.c @@ -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; }