dovecot-1.0: mail_get_stream(): If we have virtual size cached, ...
dovecot at dovecot.org
dovecot at dovecot.org
Wed Nov 28 08:11:24 EET 2007
details: http://hg.dovecot.org/dovecot-1.0/rev/0fba164c6ba6
changeset: 5463:0fba164c6ba6
user: Timo Sirainen <tss at iki.fi>
date: Wed Nov 28 08:10:17 2007 +0200
description:
mail_get_stream(): If we have virtual size cached, we don't have to read the
entire body to get its size. Instead use cached virtual size - hdr size.
diffstat:
1 file changed, 26 insertions(+), 1 deletion(-)
src/lib-storage/index/index-mail.c | 27 ++++++++++++++++++++++++++-
diffs (45 lines):
diff -r 69aea05d7b21 -r 0fba164c6ba6 src/lib-storage/index/index-mail.c
--- a/src/lib-storage/index/index-mail.c Sun Nov 25 03:15:04 2007 +0200
+++ b/src/lib-storage/index/index-mail.c Wed Nov 28 08:10:17 2007 +0200
@@ -128,6 +128,28 @@ uoff_t index_mail_get_cached_virtual_siz
return index_mail_get_cached_uoff_t(mail, MAIL_CACHE_VIRTUAL_FULL_SIZE);
}
+static void index_mail_get_cached_body_size(struct index_mail *mail)
+{
+ struct index_mail_data *data = &mail->data;
+
+ if (!data->hdr_size_set)
+ return;
+
+ data->virtual_size = index_mail_get_cached_virtual_size(mail);
+ if (data->virtual_size == (uoff_t)-1)
+ return;
+
+ (void)mail_get_physical_size(&mail->mail.mail);
+ if (data->physical_size == (uoff_t)-1)
+ return;
+
+ data->body_size.physical_size =
+ data->physical_size - data->hdr_size.physical_size;
+ data->body_size.virtual_size =
+ data->virtual_size - data->hdr_size.virtual_size;
+ data->body_size_set = TRUE;
+}
+
static uoff_t index_mail_get_cached_physical_size(struct index_mail *mail)
{
return index_mail_get_cached_uoff_t(mail,
@@ -494,8 +516,11 @@ struct istream *index_mail_init_stream(s
}
if (body_size != NULL) {
- i_stream_seek(data->stream, data->hdr_size.physical_size);
+ if (!data->body_size_set)
+ index_mail_get_cached_body_size(mail);
if (!data->body_size_set) {
+ i_stream_seek(data->stream,
+ data->hdr_size.physical_size);
if ((data->access_part & PARSE_BODY) != 0)
index_mail_parse_body(mail, FALSE);
else {
More information about the dovecot-cvs
mailing list