]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-storage optimization: SEARCH_MAILBOX* should be checked before cache lookups.
authorTimo Sirainen <tss@iki.fi>
Fri, 30 Apr 2010 12:35:59 +0000 (15:35 +0300)
committerTimo Sirainen <tss@iki.fi>
Fri, 30 Apr 2010 12:35:59 +0000 (15:35 +0300)
--HG--
branch : HEAD

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

index 00792f4369f2a72901a219e39208571a4620904e..2ff9b298d537b9febd1232920ded00c18254d94c 100644 (file)
@@ -150,6 +150,8 @@ static int search_arg_match_index(struct index_search_context *ctx,
                                  struct mail_search_arg *arg,
                                  const struct mail_index_record *rec)
 {
+       uint8_t guid[MAIL_GUID_128_SIZE];
+       const char *str;
        enum mail_flags flags;
        uint64_t modseq;
        int ret;
@@ -184,6 +186,25 @@ static int search_arg_match_index(struct index_search_context *ctx,
                }
                return modseq >= arg->value.modseq->modseq;
        }
+       case SEARCH_MAILBOX:
+               if (mail_get_special(ctx->mail, MAIL_FETCH_MAILBOX_NAME,
+                                    &str) < 0)
+                       return -1;
+
+               if (strcasecmp(str, "INBOX") == 0)
+                       return strcasecmp(arg->value.str, "INBOX") == 0;
+               return strcmp(str, arg->value.str) == 0;
+       case SEARCH_MAILBOX_GUID:
+               if (mailbox_get_guid(ctx->mail->box, guid) < 0)
+                       return -1;
+
+               return strcmp(mail_guid_128_to_string(guid),
+                             arg->value.str) == 0;
+       case SEARCH_MAILBOX_GLOB:
+               if (mail_get_special(ctx->mail, MAIL_FETCH_MAILBOX_NAME,
+                                    &str) < 0)
+                       return -1;
+               return imap_match(arg->value.mailbox_glob, str) == IMAP_MATCH_YES;
        default:
                return -1;
        }
@@ -218,7 +239,6 @@ static int search_arg_match_cached(struct index_search_context *ctx,
        time_t date;
        int tz_offset;
        bool have_tz_offset;
-       uint8_t guid[MAIL_GUID_128_SIZE];
 
        switch (arg->type) {
        /* internal dates */
@@ -279,25 +299,6 @@ static int search_arg_match_cached(struct index_search_context *ctx,
                if (mail_get_special(ctx->mail, MAIL_FETCH_GUID, &str) < 0)
                        return -1;
                return strcmp(str, arg->value.str) == 0;
-       case SEARCH_MAILBOX:
-               if (mail_get_special(ctx->mail, MAIL_FETCH_MAILBOX_NAME,
-                                    &str) < 0)
-                       return -1;
-
-               if (strcasecmp(str, "INBOX") == 0)
-                       return strcasecmp(arg->value.str, "INBOX") == 0;
-               return strcmp(str, arg->value.str) == 0;
-       case SEARCH_MAILBOX_GUID:
-               if (mailbox_get_guid(ctx->mail->box, guid) < 0)
-                       return -1;
-
-               return strcmp(mail_guid_128_to_string(guid),
-                             arg->value.str) == 0;
-       case SEARCH_MAILBOX_GLOB:
-               if (mail_get_special(ctx->mail, MAIL_FETCH_MAILBOX_NAME,
-                                    &str) < 0)
-                       return -1;
-               return imap_match(arg->value.mailbox_glob, str) == IMAP_MATCH_YES;
        default:
                return -1;
        }