dovecot-2.2: mail-index: move expunge handler init into helper f...

dovecot at dovecot.org dovecot at dovecot.org
Mon Jun 2 11:53:49 UTC 2014


details:   http://hg.dovecot.org/dovecot-2.2/rev/211c9493aaa4
changeset: 17420:211c9493aaa4
user:      Phil Carmody <phil at dovecot.fi>
date:      Mon Jun 02 14:50:34 2014 +0300
description:
mail-index: move expunge handler init into helper function
Preparatory for later optimisation patches where the call to this will
be lifted out of the expunge(seq1,seq2) inner function and done once
for the whole range of seqs in one go.

Based on draft patch by Timo Sirainen.

Signed-off-by: Phil Carmody <phil at dovecot.fi>

diffstat:

 src/lib-index/mail-index-sync-update.c |  28 +++++++++++++++++-----------
 1 files changed, 17 insertions(+), 11 deletions(-)

diffs (52 lines):

diff -r 8aa0cd95d6a8 -r 211c9493aaa4 src/lib-index/mail-index-sync-update.c
--- a/src/lib-index/mail-index-sync-update.c	Mon Jun 02 04:16:08 2014 +0300
+++ b/src/lib-index/mail-index-sync-update.c	Mon Jun 02 14:50:34 2014 +0300
@@ -206,16 +206,6 @@
 	struct mail_index_record *rec;
 	uint32_t seq;
 
-	/* call expunge handlers only when syncing index file */
-	if (ctx->type != MAIL_INDEX_SYNC_HANDLER_FILE)
-		return;
-
-	if (!ctx->expunge_handlers_set)
-		mail_index_sync_init_expunge_handlers(ctx);
-
-	if (!array_is_created(&ctx->expunge_handlers))
-		return;
-
 	array_foreach(&ctx->expunge_handlers, eh) {
 		for (seq = seq1; seq <= seq2; seq++) {
 			rec = MAIL_INDEX_MAP_IDX(ctx->view->map, seq-1);
@@ -230,6 +220,21 @@
 	}
 }
 
+static bool
+sync_expunge_handlers_init(struct mail_index_sync_map_ctx *ctx)
+{
+	/* call expunge handlers only when syncing index file */
+	if (ctx->type != MAIL_INDEX_SYNC_HANDLER_FILE)
+		return FALSE;
+
+	if (!ctx->expunge_handlers_set)
+		mail_index_sync_init_expunge_handlers(ctx);
+
+	if (!array_is_created(&ctx->expunge_handlers))
+		return FALSE;
+	return TRUE;
+}
+
 static void
 sync_expunge(struct mail_index_sync_map_ctx *ctx, uint32_t seq1, uint32_t seq2)
 {
@@ -237,7 +242,8 @@
 	struct mail_index_record *rec;
 	uint32_t seq_count, seq;
 
-	sync_expunge_call_handlers(ctx, seq1, seq2);
+	if (sync_expunge_handlers_init(ctx))
+		sync_expunge_call_handlers(ctx, seq1, seq2);
 
 	map = mail_index_sync_get_atomic_map(ctx);
 	for (seq = seq1; seq <= seq2; seq++) {


More information about the dovecot-cvs mailing list