dovecot-2.2: imapc: Add prefetched GUIDs to cache.

dovecot at dovecot.org dovecot at dovecot.org
Wed Mar 11 15:55:16 UTC 2015


details:   http://hg.dovecot.org/dovecot-2.2/rev/946be805b3cc
changeset: 18327:946be805b3cc
user:      Timo Sirainen <tss at iki.fi>
date:      Wed Mar 11 17:54:21 2015 +0200
description:
imapc: Add prefetched GUIDs to cache.

diffstat:

 src/lib-storage/index/imapc/imapc-mail.c |  36 ++++++++++++++++++++++++--------
 1 files changed, 27 insertions(+), 9 deletions(-)

diffs (57 lines):

diff -r 06362f6d26ca -r 946be805b3cc src/lib-storage/index/imapc/imapc-mail.c
--- a/src/lib-storage/index/imapc/imapc-mail.c	Wed Mar 11 17:29:12 2015 +0200
+++ b/src/lib-storage/index/imapc/imapc-mail.c	Wed Mar 11 17:54:21 2015 +0200
@@ -406,26 +406,44 @@
 	return 0;
 }
 
+static bool imapc_mail_get_cached_guid(struct mail *_mail)
+{
+	struct index_mail *imail = (struct index_mail *)_mail;
+	const enum index_cache_field cache_idx =
+		imail->ibox->cache_fields[MAIL_CACHE_GUID].idx;
+	string_t *str;
+
+	if (imail->data.guid != NULL) {
+		if (mail_cache_field_can_add(_mail->transaction->cache_trans,
+					     _mail->seq, cache_idx)) {
+			/* GUID was prefetched - add to cache */
+			index_mail_cache_add_idx(imail, cache_idx,
+				imail->data.guid, strlen(imail->data.guid)+1);
+		}
+		return TRUE;
+	}
+
+	str = str_new(imail->mail.data_pool, 64);
+	if (mail_cache_lookup_field(_mail->transaction->cache_view,
+				    str, imail->mail.mail.seq, cache_idx) > 0) {
+		imail->data.guid = str_c(str);
+		return TRUE;
+	}
+	return FALSE;
+}
+
 static int imapc_mail_get_guid(struct mail *_mail, const char **value_r)
 {
 	struct index_mail *imail = (struct index_mail *)_mail;
 	struct imapc_mailbox *mbox = (struct imapc_mailbox *)_mail->box;
 	const enum index_cache_field cache_idx =
 		imail->ibox->cache_fields[MAIL_CACHE_GUID].idx;
-	string_t *str;
 
-	if (imail->data.guid != NULL) {
+	if (imapc_mail_get_cached_guid(_mail)) {
 		*value_r = imail->data.guid;
 		return 0;
 	}
 
-	str = str_new(imail->mail.data_pool, 64);
-	if (mail_cache_lookup_field(_mail->transaction->cache_view,
-				    str, imail->mail.mail.seq, cache_idx) > 0) {
-		*value_r = str_c(str);
-		return 0;
-	}
-
 	/* GUID not in cache, fetch it */
 	if (mbox->guid_fetch_field_name != NULL) {
 		if (imapc_mail_fetch(_mail, MAIL_FETCH_GUID, NULL) < 0)


More information about the dovecot-cvs mailing list