dovecot-1.2: Moved search update result checks to search_next_up...

dovecot at dovecot.org dovecot at dovecot.org
Sun Nov 23 02:40:15 EET 2008


details:   http://hg.dovecot.org/dovecot-1.2/rev/9db582413fef
changeset: 8481:9db582413fef
user:      Timo Sirainen <tss at iki.fi>
date:      Sun Nov 23 02:36:55 2008 +0200
description:
Moved search update result checks to search_next_update_seq().

diffstat:

1 file changed, 25 insertions(+), 26 deletions(-)
src/lib-storage/index/index-search.c |   51 ++++++++++++++++------------------

diffs (97 lines):

diff -r f0c9677bf489 -r 9db582413fef src/lib-storage/index/index-search.c
--- a/src/lib-storage/index/index-search.c	Sun Nov 23 02:36:08 2008 +0200
+++ b/src/lib-storage/index/index-search.c	Sun Nov 23 02:36:55 2008 +0200
@@ -1164,7 +1164,7 @@ int index_storage_search_next_nonblock(s
         struct index_search_context *ctx = (struct index_search_context *)_ctx;
 	struct mailbox *box = _ctx->transaction->box;
 	unsigned int count = 0;
-	bool match = FALSE, never;
+	bool match = FALSE;
 
 	*tryagain_r = FALSE;
 
@@ -1186,24 +1186,7 @@ int index_storage_search_next_nonblock(s
 	while (box->v.search_next_update_seq(_ctx)) {
 		mail_set_seq(mail, _ctx->seq);
 
-		if (_ctx->update_result == NULL)
-			never = FALSE;
-		else {
-			/* see if this message never matches */
-			never = seq_range_exists(&_ctx->update_result->never_uids,
-						 mail->uid);
-			if (!never &&
-			    seq_range_exists(&_ctx->update_result->uids,
-					     mail->uid)) {
-				/* we already know that the static data
-				   matches. mark it as such. */
-				search_set_static_matches(_ctx->args->args);
-			}
-		}
-
-		if (never) {
-			match = FALSE;
-		} else T_BEGIN {
+		T_BEGIN {
 			match = search_match_next(ctx);
 
 			if (ctx->mail->expunged)
@@ -1251,6 +1234,7 @@ bool index_storage_search_next_update_se
 bool index_storage_search_next_update_seq(struct mail_search_context *_ctx)
 {
         struct index_search_context *ctx = (struct index_search_context *)_ctx;
+	uint32_t uid;
 	int ret;
 
 	if (_ctx->seq == 0) {
@@ -1260,7 +1244,8 @@ bool index_storage_search_next_update_se
 		_ctx->seq++;
 	}
 
-	if (!ctx->have_seqsets && !ctx->have_index_args)
+	if (!ctx->have_seqsets && !ctx->have_index_args &&
+	    _ctx->update_result == NULL)
 		return _ctx->seq <= ctx->seq2;
 
 	ret = 0;
@@ -1268,20 +1253,34 @@ bool index_storage_search_next_update_se
 		/* check if the sequence matches */
 		ret = mail_search_args_foreach(ctx->mail_ctx.args->args,
 					       search_seqset_arg, ctx);
-		if (ret != 0) {
+		if (ret != 0 && ctx->have_index_args) {
 			/* check if flags/keywords match before anything else
 			   is done. mail_set_seq() can be a bit slow. */
-			if (!ctx->have_index_args)
-				break;
 			ret = mail_search_args_foreach(ctx->mail_ctx.args->args,
 						       search_index_arg, ctx);
-			if (ret != 0)
-				break;
-		}
+		}
+		if (ret != 0 && _ctx->update_result != NULL) {
+			/* see if this message never matches */
+			mail_index_lookup_uid(ctx->view, _ctx->seq, &uid);
+			if (seq_range_exists(&_ctx->update_result->never_uids,
+					     uid))
+				ret = 0;
+		}
+		if (ret != 0)
+			break;
 
 		/* doesn't, try next one */
 		_ctx->seq++;
 		mail_search_args_reset(ctx->mail_ctx.args->args, FALSE);
 	}
+
+	if (ret != 0 && _ctx->update_result != NULL) {
+		mail_index_lookup_uid(ctx->view, _ctx->seq, &uid);
+		if (seq_range_exists(&_ctx->update_result->uids, uid)) {
+			/* we already know that the static data
+			   matches. mark it as such. */
+			search_set_static_matches(_ctx->args->args);
+		}
+	}
 	return ret != 0;
 }


More information about the dovecot-cvs mailing list