dovecot-2.2: mail-index: use _REC_AT_SEQ not _MAP_IDX in view_sy...

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


details:   http://hg.dovecot.org/dovecot-2.2/rev/26e097feb136
changeset: 17432:26e097feb136
user:      Phil Carmody <phil at dovecot.fi>
date:      Mon Jun 02 14:50:34 2014 +0300
description:
mail-index: use _REC_AT_SEQ not _MAP_IDX in view_sync_get_log_lost_changes
Shifting i and j up by one to use in the new macro means we don't
need the +1's in the calls to view_sync_apply_lost_changes and
mail_index_map_lookup_keywords. Rename them as seq variables too.

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

diffstat:

 src/lib-index/mail-index-view-sync.c |  26 +++++++++++++-------------
 1 files changed, 13 insertions(+), 13 deletions(-)

diffs (64 lines):

diff -r b579e315d9a8 -r 26e097feb136 src/lib-index/mail-index-view-sync.c
--- a/src/lib-index/mail-index-view-sync.c	Mon Jun 02 14:50:34 2014 +0300
+++ b/src/lib-index/mail-index-view-sync.c	Mon Jun 02 14:50:34 2014 +0300
@@ -410,7 +410,7 @@
 	const unsigned int new_count = new_map->hdr.messages_count;
 	const struct mail_index_record *old_rec, *new_rec;
 	struct mail_transaction_header thdr;
-	unsigned int i, j;
+	uint32_t seqi, seqj;
 
 	/* we don't update the map in the same order as it's typically done.
 	   map->rec_map may already have some messages appended that we don't
@@ -427,19 +427,19 @@
 	ctx->lost_kw_buf = buffer_create_dynamic(pool_datastack_create(), 128);
 
 	/* handle expunges and sync flags */
-	i = j = 0;
-	while (i < old_count && j < new_count) {
-		old_rec = MAIL_INDEX_MAP_IDX(old_map, i);
-		new_rec = MAIL_INDEX_MAP_IDX(new_map, j);
+	seqi = seqj = 1;
+	while (seqi < old_count && seqj < new_count) {
+		old_rec = MAIL_INDEX_REC_AT_SEQ(old_map, seqi);
+		new_rec = MAIL_INDEX_REC_AT_SEQ(new_map, seqj);
 		if (old_rec->uid == new_rec->uid) {
 			/* message found - check if flags have changed */
-			if (view_sync_apply_lost_changes(ctx, i + 1, j + 1) < 0)
+			if (view_sync_apply_lost_changes(ctx, seqi, seqj) < 0)
 				return -1;
-			i++; j++;
+			seqi++; seqj++;
 		} else if (old_rec->uid < new_rec->uid) {
 			/* message expunged */
 			seq_range_array_add(&ctx->expunges, old_rec->uid);
-			i++;
+			seqi++;
 		} else {
 			/* new message appeared out of nowhere */
 			mail_index_set_error(view->index,
@@ -450,19 +450,19 @@
 		}
 	}
 	/* if there are old messages left, they're all expunged */
-	for (; i < old_count; i++) {
-		old_rec = MAIL_INDEX_MAP_IDX(old_map, i);
+	for (; seqi <= old_count; seqi++) {
+		old_rec = MAIL_INDEX_REC_AT_SEQ(old_map, seqi);
 		seq_range_array_add(&ctx->expunges, old_rec->uid);
 	}
 	/* if there are new messages left, they're all new messages */
 	thdr.type = MAIL_TRANSACTION_APPEND | MAIL_TRANSACTION_EXTERNAL;
 	thdr.size = sizeof(*new_rec);
-	for (; j < new_count; j++) {
-		new_rec = MAIL_INDEX_MAP_IDX(new_map, j);
+	for (; seqj <= new_count; seqj++) {
+		new_rec = MAIL_INDEX_REC_AT_SEQ(new_map, seqj);
 		if (mail_index_sync_record(&ctx->sync_map_ctx,
 					   &thdr, new_rec) < 0)
 			return -1;
-		mail_index_map_lookup_keywords(new_map, j + 1,
+		mail_index_map_lookup_keywords(new_map, seqj,
 					       &ctx->lost_new_kw);
 		if (view_sync_update_keywords(ctx, new_rec->uid) < 0)
 			return -1;


More information about the dovecot-cvs mailing list