From: Timo Sirainen Date: Fri, 30 Apr 2010 12:35:59 +0000 (+0300) Subject: lib-storage optimization: SEARCH_MAILBOX* should be checked before cache lookups. X-Git-Tag: 2.0.beta5~40 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=85089540d28838579248ea6a62ef27007b2b4027;p=thirdparty%2Fdovecot%2Fcore.git lib-storage optimization: SEARCH_MAILBOX* should be checked before cache lookups. --HG-- branch : HEAD --- diff --git a/src/lib-storage/index/index-search.c b/src/lib-storage/index/index-search.c index 00792f4369..2ff9b298d5 100644 --- a/src/lib-storage/index/index-search.c +++ b/src/lib-storage/index/index-search.c @@ -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; }