]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
mail_index_bsearch_uid(): Small optimization.
authorTimo Sirainen <tss@iki.fi>
Thu, 6 Mar 2008 08:26:52 +0000 (10:26 +0200)
committerTimo Sirainen <tss@iki.fi>
Thu, 6 Mar 2008 08:26:52 +0000 (10:26 +0200)
--HG--
branch : HEAD

src/lib-index/mail-index-view.c

index 3d1f10fb397f6754818de0bf3a6e23c43faf9fca..290ea02119e1b0f67b1bfff192a3e9bdc0e87ea0 100644 (file)
@@ -222,15 +222,11 @@ static uint32_t mail_index_bsearch_uid(struct mail_index_view *view,
        i_assert(view->map->hdr.messages_count <=
                 view->map->rec_map->records_count);
 
-       if (uid == 1) {
-               /* optimization: the message can be only the first one */
-               return 1;
-       }
        rec_base = view->map->rec_map->records;
        record_size = view->map->hdr.record_size;
 
        idx = left_idx;
-       right_idx = view->map->hdr.messages_count;
+       right_idx = I_MIN(view->map->hdr.messages_count, uid);
 
        while (left_idx < right_idx) {
                idx = (left_idx + right_idx) / 2;