comparison src/plugins/virtual/virtual-sync.c @ 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 00cd9aacd03c
comparison
equal deleted inserted replaced
9500:9cccb8617820 9501:f1c4c0c90da1
696 MAILBOX_SEARCH_RESULT_FLAG_UPDATE | 696 MAILBOX_SEARCH_RESULT_FLAG_UPDATE |
697 MAILBOX_SEARCH_RESULT_FLAG_QUEUE_SYNC; 697 MAILBOX_SEARCH_RESULT_FLAG_QUEUE_SYNC;
698 struct index_mailbox *ibox = (struct index_mailbox *)bbox->box; 698 struct index_mailbox *ibox = (struct index_mailbox *)bbox->box;
699 struct mail_search_result *result; 699 struct mail_search_result *result;
700 ARRAY_TYPE(seq_range) removed_uids, added_uids, flag_update_uids; 700 ARRAY_TYPE(seq_range) removed_uids, added_uids, flag_update_uids;
701 uint64_t modseq; 701 uint64_t modseq, old_highest_modseq;
702 uint32_t seq, uid, old_msg_count; 702 uint32_t seq, uid, old_msg_count;
703 703
704 /* initialize the search result from all the existing messages in 704 /* initialize the search result from all the existing messages in
705 virtual index. */ 705 virtual index. */
706 result = mailbox_search_result_alloc(bbox->box, bbox->search_args, 706 result = mailbox_search_result_alloc(bbox->box, bbox->search_args,
713 changes are due to flag changes, which may not be true in future) */ 713 changes are due to flag changes, which may not be true in future) */
714 if (bbox->sync_next_uid <= 1 || 714 if (bbox->sync_next_uid <= 1 ||
715 !mail_index_lookup_seq_range(ibox->view, 1, bbox->sync_next_uid-1, 715 !mail_index_lookup_seq_range(ibox->view, 1, bbox->sync_next_uid-1,
716 &seq, &old_msg_count)) 716 &seq, &old_msg_count))
717 old_msg_count = 0; 717 old_msg_count = 0;
718 old_highest_modseq = mail_index_modseq_get_highest(ibox->view);
719
718 t_array_init(&flag_update_uids, I_MIN(128, old_msg_count)); 720 t_array_init(&flag_update_uids, I_MIN(128, old_msg_count));
719 for (seq = 1; seq <= old_msg_count; seq++) { 721 if (bbox->sync_highest_modseq < old_highest_modseq) {
720 modseq = mail_index_modseq_lookup(ibox->view, seq); 722 for (seq = 1; seq <= old_msg_count; seq++) {
721 if (modseq > bbox->sync_highest_modseq) { 723 modseq = mail_index_modseq_lookup(ibox->view, seq);
722 mail_index_lookup_uid(ibox->view, seq, &uid); 724 if (modseq > bbox->sync_highest_modseq) {
723 seq_range_array_add(&flag_update_uids, 0, uid); 725 mail_index_lookup_uid(ibox->view, seq, &uid);
726 seq_range_array_add(&flag_update_uids, 0, uid);
727 }
724 } 728 }
725 } 729 }
726 730
727 /* update the search result based on the flag changes and 731 /* update the search result based on the flag changes and
728 new messages */ 732 new messages */