changeset 5992:ac382879b116 HEAD

If we're modifying just one extension record, don't write the ext intro twice.
author Timo Sirainen <tss@iki.fi>
date Sat, 14 Jul 2007 23:16:20 +0300
parents 5dacddf4a88a
children c66c80b23f95
files src/lib-index/mail-transaction-log-append.c
diffstat 1 files changed, 8 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/lib-index/mail-transaction-log-append.c	Sat Jul 14 23:15:54 2007 +0300
+++ b/src/lib-index/mail-transaction-log-append.c	Sat Jul 14 23:16:20 2007 +0300
@@ -14,6 +14,8 @@
 	struct mail_index_transaction *trans;
 	buffer_t *output;
 
+	uint32_t last_ext_id, last_reset_id;
+
 	uint32_t first_append_size;
 	bool sync_includes_this;
 };
@@ -222,7 +224,11 @@
 	if ((buf->used % 4) != 0)
 		buffer_append_zero(buf, 4 - (buf->used % 4));
 
-	log_append_buffer(ctx, buf, NULL, MAIL_TRANSACTION_EXT_INTRO);
+	if (ctx->last_ext_id != ext_id || intro->reset_id != ctx->last_reset_id)
+		log_append_buffer(ctx, buf, NULL, MAIL_TRANSACTION_EXT_INTRO);
+
+	ctx->last_ext_id = ext_id;
+	ctx->last_reset_id = intro->reset_id;
 }
 
 static void
@@ -486,6 +492,7 @@
 	ctx.file = file;
 	ctx.trans = t;
 	ctx.output = buffer_create_dynamic(default_pool, 1024);
+	ctx.last_ext_id = (uint32_t)-1;
 
 	/* send all extension introductions and resizes before appends
 	   to avoid resize overhead as much as possible */