Mercurial > dovecot > original-hg > dovecot-1.2
changeset 9501:f1c4c0c90da1 HEAD
virtual optimization: If saved highest-modseq matches current one, don't try to find higher ones.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Wed, 09 Dec 2009 18:58:13 -0500 |
parents | 9cccb8617820 |
children | 91c6b067f464 |
files | src/plugins/virtual/virtual-sync.c |
diffstat | 1 files changed, 10 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/src/plugins/virtual/virtual-sync.c Wed Dec 09 18:47:27 2009 -0500 +++ b/src/plugins/virtual/virtual-sync.c Wed Dec 09 18:58:13 2009 -0500 @@ -698,7 +698,7 @@ struct index_mailbox *ibox = (struct index_mailbox *)bbox->box; struct mail_search_result *result; ARRAY_TYPE(seq_range) removed_uids, added_uids, flag_update_uids; - uint64_t modseq; + uint64_t modseq, old_highest_modseq; uint32_t seq, uid, old_msg_count; /* initialize the search result from all the existing messages in @@ -715,12 +715,16 @@ !mail_index_lookup_seq_range(ibox->view, 1, bbox->sync_next_uid-1, &seq, &old_msg_count)) old_msg_count = 0; + old_highest_modseq = mail_index_modseq_get_highest(ibox->view); + t_array_init(&flag_update_uids, I_MIN(128, old_msg_count)); - for (seq = 1; seq <= old_msg_count; seq++) { - modseq = mail_index_modseq_lookup(ibox->view, seq); - if (modseq > bbox->sync_highest_modseq) { - mail_index_lookup_uid(ibox->view, seq, &uid); - seq_range_array_add(&flag_update_uids, 0, uid); + if (bbox->sync_highest_modseq < old_highest_modseq) { + for (seq = 1; seq <= old_msg_count; seq++) { + modseq = mail_index_modseq_lookup(ibox->view, seq); + if (modseq > bbox->sync_highest_modseq) { + mail_index_lookup_uid(ibox->view, seq, &uid); + seq_range_array_add(&flag_update_uids, 0, uid); + } } }