dovecot-2.2: mail-index: make uid_lookup_idx hold a sequence num...

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/2d5c66e8d77c
changeset: 17433:2d5c66e8d77c
user:      Phil Carmody <phil at dovecot.fi>
date:      Mon Jun 02 14:50:34 2014 +0300
description:
mail-index: make uid_lookup_idx hold a sequence number, not a 0-based C array index
Rename it to _seq, and make it hold values 1.. rather than 0.. . Several
uses of the value are simplified by this change, and none are made more
confusing, so I think it helps improve maintainability of the code.

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

diffstat:

 src/lib-index/mail-index-strmap.c |  12 ++++++------
 1 files changed, 6 insertions(+), 6 deletions(-)

diffs (51 lines):

diff -r 26e097feb136 -r 2d5c66e8d77c src/lib-index/mail-index-strmap.c
--- a/src/lib-index/mail-index-strmap.c	Mon Jun 02 14:50:34 2014 +0300
+++ b/src/lib-index/mail-index-strmap.c	Mon Jun 02 14:50:34 2014 +0300
@@ -57,7 +57,7 @@
 	struct istream *input;
 	uoff_t end_offset;
 	uint32_t highest_str_idx;
-	uint32_t uid_lookup_idx;
+	uint32_t uid_lookup_seq;
 	uint32_t lost_expunged_uid;
 
 	const unsigned char *data, *end, *str_idx_base;
@@ -381,7 +381,7 @@
 {
 	const struct mail_index_record *rec;
 
-	if (ctx->uid_lookup_idx >= ctx->view->view->map->hdr.messages_count) {
+	if (ctx->uid_lookup_seq > ctx->view->view->map->hdr.messages_count) {
 		if (uid >= ctx->view->view->map->hdr.next_uid) {
 			/* thread index has larger UIDs than what we've seen
 			   in our view. we'll have to read them again later
@@ -391,9 +391,9 @@
 		return 0;
 	}
 
-	rec = MAIL_INDEX_MAP_IDX(ctx->view->view->map, ctx->uid_lookup_idx);
+	rec = MAIL_INDEX_REC_AT_SEQ(ctx->view->view->map, ctx->uid_lookup_seq);
 	if (rec->uid == uid) {
-		ctx->uid_lookup_idx++;
+		ctx->uid_lookup_seq++;
 		return 1;
 	} else if (rec->uid > uid) {
 		return 0;
@@ -404,7 +404,7 @@
 		   been expunged. */
 		mail_index_refresh(ctx->view->view->index);
 		if (mail_index_is_expunged(ctx->view->view,
-					   ctx->uid_lookup_idx + 1))
+					   ctx->uid_lookup_seq))
 			ctx->lost_expunged_uid = rec->uid;
 		return -1;
 	}
@@ -541,7 +541,7 @@
 	if (!mail_index_lookup_seq_range(view->view, ctx->rec.uid, (uint32_t)-1,
 					 &seq1, &seq2))
 		seq1 = mail_index_view_get_messages_count(view->view) + 1;
-	ctx->uid_lookup_idx = seq1 - 1;
+	ctx->uid_lookup_seq = seq1;
 	return 1;
 }
 


More information about the dovecot-cvs mailing list