From: Phil Carmody Date: Mon, 2 Jun 2014 11:50:34 +0000 (+0300) Subject: mail-index: Preparatory HACK - reverse the loop order in the expunge X-Git-Tag: 2.2.14.rc1~446 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=aba9cc9bf97576c0ca653d4e218567e617061029;p=thirdparty%2Fdovecot%2Fcore.git mail-index: Preparatory HACK - reverse the loop order in the expunge This is the final step before the actual optimisation of the memmoves. HACK, as it it de-optimises the moves so as much as possible gets moved as many times as possible. It clears the path for a later patch which optimises them far better. Based on draft patch by Timo Sirainen. Signed-off-by: Phil Carmody --- diff --git a/src/lib-index/mail-index-sync-update.c b/src/lib-index/mail-index-sync-update.c index 6b7b112e9d..5248cb2683 100644 --- a/src/lib-index/mail-index-sync-update.c +++ b/src/lib-index/mail-index-sync-update.c @@ -254,10 +254,10 @@ sync_expunge_range(struct mail_index_sync_map_ctx *ctx, const ARRAY_TYPE(seq_ran } } - /* do this in reverse so the memmove()s are smaller */ - for (i = count; i > 0; i--) { - uint32_t seq1 = range[i-1].seq1; - uint32_t seq2 = range[i-1].seq2; + /* Preparatory HACK - do this in forward order so the memmove()s are pessimal! */ + for (i = 0; i < count; i++) { + uint32_t seq1 = range[i].seq1; + uint32_t seq2 = range[i].seq2; struct mail_index_record *rec; uint32_t seq_count, seq;