dovecot-2.2: mail-index: explicitly inline contents of sync_expu...

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


details:   http://hg.dovecot.org/dovecot-2.2/rev/25ce8f635980
changeset: 17422:25ce8f635980
user:      Phil Carmody <phil at dovecot.fi>
date:      Mon Jun 02 14:50:34 2014 +0300
description:
mail-index: explicitly inline contents of sync_expunge()
To later optimise the memmoves, we will need to be aware of previous seqs.
It's easier to just have the guts inlined, so too much state doesn't need
to be passed around.

For review, this change is best viewed with a whitespace-insensitive diff,
to verify that the new contents of the loop are identical to the contents of
the now-absorbed function.

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 |  49 +++++++++++++++------------------
 1 files changed, 23 insertions(+), 26 deletions(-)

diffs (66 lines):

diff -r aa6e69727edb -r 25ce8f635980 src/lib-index/mail-index-sync-update.c
--- a/src/lib-index/mail-index-sync-update.c	Mon Jun 02 14:50:34 2014 +0300
+++ b/src/lib-index/mail-index-sync-update.c	Mon Jun 02 14:50:34 2014 +0300
@@ -236,30 +236,6 @@
 }
 
 static void
-sync_expunge(struct mail_index_sync_map_ctx *ctx, uint32_t seq1, uint32_t seq2)
-{
-	struct mail_index_map *map;
-	struct mail_index_record *rec;
-	uint32_t seq_count, seq;
-
-	map = mail_index_sync_get_atomic_map(ctx);
-	for (seq = seq1; seq <= seq2; seq++) {
-		rec = MAIL_INDEX_MAP_IDX(map, seq-1);
-		mail_index_sync_header_update_counts(ctx, rec->uid, rec->flags, 0);
-	}
-
-	/* @UNSAFE */
-	memmove(MAIL_INDEX_MAP_IDX(map, seq1-1),
-		MAIL_INDEX_MAP_IDX(map, seq2),
-		(map->rec_map->records_count - seq2) * map->hdr.record_size);
-
-	seq_count = seq2 - seq1 + 1;
-	map->rec_map->records_count -= seq_count;
-	map->hdr.messages_count -= seq_count;
-	mail_index_modseq_expunge(ctx->modseq_ctx, seq1, seq2);
-}
-
-static void
 sync_expunge_range(struct mail_index_sync_map_ctx *ctx, const ARRAY_TYPE(seq_range) *seqs)
 {
 	const struct seq_range *range;
@@ -276,8 +252,29 @@
 	}
 
 	/* do this in reverse so the memmove()s are smaller */
-	for (i = count; i > 0; i--)
-		sync_expunge(ctx, range[i-1].seq1, range[i-1].seq2);
+	for (i = count; i > 0; i--) {
+		uint32_t seq1 = range[i-1].seq1;
+		uint32_t seq2 = range[i-1].seq2;
+		struct mail_index_map *map;
+		struct mail_index_record *rec;
+		uint32_t seq_count, seq;
+
+		map = mail_index_sync_get_atomic_map(ctx);
+		for (seq = seq1; seq <= seq2; seq++) {
+			rec = MAIL_INDEX_MAP_IDX(map, seq-1);
+			mail_index_sync_header_update_counts(ctx, rec->uid, rec->flags, 0);
+		}
+
+		/* @UNSAFE */
+		memmove(MAIL_INDEX_MAP_IDX(map, seq1-1),
+			MAIL_INDEX_MAP_IDX(map, seq2),
+			(map->rec_map->records_count - seq2) * map->hdr.record_size);
+
+		seq_count = seq2 - seq1 + 1;
+		map->rec_map->records_count -= seq_count;
+		map->hdr.messages_count -= seq_count;
+		mail_index_modseq_expunge(ctx->modseq_ctx, seq1, seq2);
+	}
 }
 
 static void *sync_append_record(struct mail_index_map *map)


More information about the dovecot-cvs mailing list