]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-storage: Minor optimization - Use mail_index_lookup_full() to avoid two index...
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Mon, 29 Nov 2021 15:21:29 +0000 (16:21 +0100)
committeraki.tuomi <aki.tuomi@open-xchange.com>
Tue, 21 Dec 2021 10:06:58 +0000 (10:06 +0000)
mail_index_is_expunged() was already internally doing the full lookup.

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

index 238c95b1fb2795b98b84f8ed4d4ddcf97e02c971..aedf620a1a7fdf0f7f145773c6b2f20e8d39d2fe 100644 (file)
@@ -2109,6 +2109,9 @@ void index_mail_update_access_parts_post(struct mail *_mail)
 void index_mail_set_seq(struct mail *_mail, uint32_t seq, bool saving)
 {
        struct index_mail *mail = INDEX_MAIL(_mail);
+       const struct mail_index_record *rec;
+       struct mail_index_map *map;
+       bool expunged;
 
        if (mail->data.seq == seq) {
                if (!saving)
@@ -2123,8 +2126,10 @@ void index_mail_set_seq(struct mail *_mail, uint32_t seq, bool saving)
        mail->data.seq = seq;
        mail->mail.mail.seq = seq;
        mail->mail.mail.saving = saving;
-       mail_index_lookup_uid(_mail->transaction->view, seq,
-                             &mail->mail.mail.uid);
+
+       rec = mail_index_lookup_full(_mail->transaction->view, seq,
+                                    &map, &expunged);
+       mail->mail.mail.uid = rec->uid;
 
        /* Recreate the mail event when changing mails. Even though the same
           mail struct is reused, they are practically different mails. The
@@ -2138,7 +2143,7 @@ void index_mail_set_seq(struct mail *_mail, uint32_t seq, bool saving)
        /* Allow callers to easily find out if this mail was already expunged
           by another session. It's possible that it could still be
           successfully accessed. */
-       if (mail_index_is_expunged(_mail->transaction->view, seq))
+       if (expunged)
                mail_set_expunged(&mail->mail.mail);
 
        if (!mail->mail.search_mail) {