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

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/d3564b417e77
changeset: 17430:d3564b417e77
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 loops from [seq1..seq2]
[seq1-1..seq2) becomes [seq1..seq2]

Don't decrement before starting, and include the upper bound.

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

diffstat:

 src/lib-index/mail-index-sync-keywords.c |  12 ++++++------
 src/lib-index/mail-index-sync-update.c   |  10 +++++-----
 2 files changed, 11 insertions(+), 11 deletions(-)

diffs (65 lines):

diff -r 293966cc6e39 -r d3564b417e77 src/lib-index/mail-index-sync-keywords.c
--- a/src/lib-index/mail-index-sync-keywords.c	Mon Jun 02 14:50:34 2014 +0300
+++ b/src/lib-index/mail-index-sync-keywords.c	Mon Jun 02 14:50:34 2014 +0300
@@ -228,16 +228,16 @@
 
 	switch (type) {
 	case MODIFY_ADD:
-		for (seq1--; seq1 < seq2; seq1++) {
-			rec = MAIL_INDEX_MAP_IDX(view->map, seq1);
+		for (; seq1 <= seq2; seq1++) {
+			rec = MAIL_INDEX_REC_AT_SEQ(view->map, seq1);
 			data = PTR_OFFSET(rec, data_offset);
 			*data |= data_mask;
 		}
 		break;
 	case MODIFY_REMOVE:
 		data_mask = ~data_mask;
-		for (seq1--; seq1 < seq2; seq1++) {
-			rec = MAIL_INDEX_MAP_IDX(view->map, seq1);
+		for (; seq1 <= seq2; seq1++) {
+			rec = MAIL_INDEX_REC_AT_SEQ(view->map, seq1);
 			data = PTR_OFFSET(rec, data_offset);
 			*data &= data_mask;
 		}
@@ -337,8 +337,8 @@
 			continue;
 
 		mail_index_modseq_reset_keywords(ctx->modseq_ctx, seq1, seq2);
-		for (seq1--; seq1 < seq2; seq1++) {
-			rec = MAIL_INDEX_MAP_IDX(map, seq1);
+		for (; seq1 <= seq2; seq1++) {
+			rec = MAIL_INDEX_REC_AT_SEQ(map, seq1);
 			memset(PTR_OFFSET(rec, ext->record_offset),
 			       0, ext->record_size);
 		}
diff -r 293966cc6e39 -r d3564b417e77 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
@@ -434,7 +434,7 @@
 	struct mail_index_view *view = ctx->view;
 	struct mail_index_record *rec;
 	uint8_t flag_mask, old_flags;
-	uint32_t idx, seq1, seq2;
+	uint32_t seq, seq1, seq2;
 
 	if (!mail_index_lookup_seq_range(view, u->uid1, u->uid2, &seq1, &seq2))
 		return 1;
@@ -453,13 +453,13 @@
 	if (((u->add_flags | u->remove_flags) &
 	     (MAIL_SEEN | MAIL_DELETED)) == 0) {
 		/* we're not modifying any counted/lowwatered flags */
-		for (idx = seq1-1; idx < seq2; idx++) {
-			rec = MAIL_INDEX_MAP_IDX(view->map, idx);
+		for (seq = seq1; seq <= seq2; seq++) {
+			rec = MAIL_INDEX_REC_AT_SEQ(view->map, seq);
 			rec->flags = (rec->flags & flag_mask) | u->add_flags;
 		}
 	} else {
-		for (idx = seq1-1; idx < seq2; idx++) {
-			rec = MAIL_INDEX_MAP_IDX(view->map, idx);
+		for (seq = seq1; seq <= seq2; seq++) {
+			rec = MAIL_INDEX_REC_AT_SEQ(view->map, seq);
 
 			old_flags = rec->flags;
 			rec->flags = (rec->flags & flag_mask) | u->add_flags;


More information about the dovecot-cvs mailing list