dovecot-2.2: lib-storage: mail_search_args_simplify() code clean...
dovecot at dovecot.org
dovecot at dovecot.org
Tue Dec 8 11:31:22 UTC 2015
details: http://hg.dovecot.org/dovecot-2.2/rev/f894dbea7226
changeset: 19490:f894dbea7226
user: Timo Sirainen <tss at iki.fi>
date: Tue Dec 08 13:13:24 2015 +0200
description:
lib-storage: mail_search_args_simplify() code cleanup - allow merging first arg
diffstat:
src/lib-storage/mail-search-args-simplify.c | 23 +++++++++++------------
1 files changed, 11 insertions(+), 12 deletions(-)
diffs (76 lines):
diff -r 93bff1584e5e -r f894dbea7226 src/lib-storage/mail-search-args-simplify.c
--- a/src/lib-storage/mail-search-args-simplify.c Tue Dec 08 13:13:10 2015 +0200
+++ b/src/lib-storage/mail-search-args-simplify.c Tue Dec 08 13:13:24 2015 +0200
@@ -461,10 +461,10 @@
static bool
mail_search_args_simplify_sub(struct mailbox *box, pool_t pool,
- struct mail_search_arg *args, bool parent_and)
+ struct mail_search_arg **argsp, bool parent_and)
{
struct mail_search_simplify_ctx ctx;
- struct mail_search_arg *sub, *prev_arg = NULL;
+ struct mail_search_arg *sub;
bool merged;
memset(&ctx, 0, sizeof(ctx));
@@ -474,7 +474,9 @@
mail_search_simplify_prev_arg_hash,
mail_search_simplify_prev_arg_cmp);
- while (args != NULL) {
+ while (*argsp != NULL) {
+ struct mail_search_arg *args = *argsp;
+
if (args->match_not && (args->type == SEARCH_SUB ||
args->type == SEARCH_OR)) {
/* neg(p and q and ..) == neg(p) or neg(q) or ..
@@ -517,7 +519,7 @@
if (mail_search_args_simplify_extract_common(&args->value.subargs, pool, and_arg))
ctx.removals = TRUE;
}
- if (mail_search_args_simplify_sub(box, pool, args->value.subargs,
+ if (mail_search_args_simplify_sub(box, pool, &args->value.subargs,
args->type != SEARCH_OR))
ctx.removals = TRUE;
}
@@ -559,15 +561,12 @@
break;
}
if (merged) {
- i_assert(prev_arg != NULL);
- prev_arg->next = args->next;
- args = args->next;
+ *argsp = args->next;
ctx.removals = TRUE;
continue;
}
- prev_arg = args;
- args = args->next;
+ argsp = &args->next;
}
hash_table_destroy(&ctx.prev_args);
pool_unref(&ctx.pool);
@@ -646,11 +645,11 @@
args->simplified = TRUE;
- removals = mail_search_args_simplify_sub(args->box, args->pool, args->args, TRUE);
+ removals = mail_search_args_simplify_sub(args->box, args->pool, &args->args, TRUE);
if (mail_search_args_unnest_inthreads(args, &args->args,
FALSE, TRUE)) {
/* we may have added some extra SUBs that could be dropped */
- if (mail_search_args_simplify_sub(args->box, args->pool, args->args, TRUE))
+ if (mail_search_args_simplify_sub(args->box, args->pool, &args->args, TRUE))
removals = TRUE;
}
for (;;) {
@@ -660,6 +659,6 @@
removals = TRUE;
if (!removals)
break;
- removals = mail_search_args_simplify_sub(args->box, args->pool, args->args, TRUE);
+ removals = mail_search_args_simplify_sub(args->box, args->pool, &args->args, TRUE);
}
}
More information about the dovecot-cvs
mailing list