Mercurial > dovecot > core-2.2
changeset 441:4d77a27f7cd1 HEAD
SEARCH SMALLER/LARGER - we may be able to handle the request using only
physical sizes, avoids calculating the virtual size in those cases
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Wed, 16 Oct 2002 04:37:25 +0300 |
parents | c54c1ca69362 |
children | 2a25bf21557b |
files | src/lib-storage/index/index-search.c |
diffstat | 1 files changed, 16 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/src/lib-storage/index/index-search.c Wed Oct 16 04:29:42 2002 +0300 +++ b/src/lib-storage/index/index-search.c Wed Oct 16 04:37:25 2002 +0300 @@ -116,7 +116,7 @@ MailSearchArgType type, const char *value) { time_t t; - uoff_t size; + uoff_t size, user_size; switch (type) { case SEARCH_ALL: @@ -161,14 +161,23 @@ /* sizes, only with fastscanning */ case SEARCH_SMALLER: - if (!mail_index_get_virtual_size(ibox->index, rec, TRUE, &size)) - return -1; - return size < str_to_uoff_t(value); + user_size = str_to_uoff_t(value); + if (mail_index_get_virtual_size(ibox->index, rec, TRUE, &size)) + return size < user_size; + + /* knowing physical size may be enough */ + if (rec->header_size + rec->body_size >= user_size) + return 0; + return -1; case SEARCH_LARGER: - if (!mail_index_get_virtual_size(ibox->index, rec, TRUE, &size)) - return -1; - return size > str_to_uoff_t(value); + user_size = str_to_uoff_t(value); + if (mail_index_get_virtual_size(ibox->index, rec, TRUE, &size)) + return size > user_size; + /* knowing physical size may be enough */ + if (rec->header_size + rec->body_size > user_size) + return 1; + return -1; default: return -1; }