dovecot: Removed view->hdr. Use view->map->hdr directly.

dovecot at dovecot.org dovecot at dovecot.org
Sun Jul 1 22:11:50 EEST 2007


details:   http://hg.dovecot.org/dovecot/rev/fd6ff4d9cab1
changeset: 5855:fd6ff4d9cab1
user:      Timo Sirainen <tss at iki.fi>
date:      Sun Jul 01 22:11:41 2007 +0300
description:
Removed view->hdr. Use view->map->hdr directly.

diffstat:

5 files changed, 17 insertions(+), 42 deletions(-)
src/lib-index/mail-index-sync-update.c      |    4 ---
src/lib-index/mail-index-transaction-view.c |    2 -
src/lib-index/mail-index-view-private.h     |    2 -
src/lib-index/mail-index-view-sync.c        |   21 +-----------------
src/lib-index/mail-index-view.c             |   30 ++++++++++++---------------

diffs (220 lines):

diff -r eca7e29dce0d -r fd6ff4d9cab1 src/lib-index/mail-index-sync-update.c
--- a/src/lib-index/mail-index-sync-update.c	Sun Jul 01 22:05:09 2007 +0300
+++ b/src/lib-index/mail-index-sync-update.c	Sun Jul 01 22:11:41 2007 +0300
@@ -277,9 +277,6 @@ sync_expunge(const struct mail_transacti
 		seq_count = seq2 - seq1 + 1;
 		map->records_count -= seq_count;
 		map->hdr.messages_count -= seq_count;
-
-		/* lookup_uid_range() relies on this */
-		ctx->view->hdr.messages_count -= seq_count;
 	}
 	return 1;
 }
@@ -615,7 +612,6 @@ int mail_index_sync_record(struct mail_i
 
 	i_assert(ctx->view->map->records_count ==
 		 ctx->view->map->hdr.messages_count);
-	ctx->view->hdr = ctx->view->map->hdr;
 	return ret;
 }
 
diff -r eca7e29dce0d -r fd6ff4d9cab1 src/lib-index/mail-index-transaction-view.c
--- a/src/lib-index/mail-index-transaction-view.c	Sun Jul 01 22:05:09 2007 +0300
+++ b/src/lib-index/mail-index-transaction-view.c	Sun Jul 01 22:11:41 2007 +0300
@@ -31,7 +31,7 @@ static uint32_t _tview_get_message_count
 	struct mail_index_view_transaction *tview =
                 (struct mail_index_view_transaction *)view;
 
-	return view->hdr.messages_count +
+	return view->map->hdr.messages_count +
 		(tview->t->last_new_seq == 0 ? 0 :
 		 tview->t->last_new_seq - tview->t->first_new_seq);
 }
diff -r eca7e29dce0d -r fd6ff4d9cab1 src/lib-index/mail-index-view-private.h
--- a/src/lib-index/mail-index-view-private.h	Sun Jul 01 22:05:09 2007 +0300
+++ b/src/lib-index/mail-index-view-private.h	Sun Jul 01 22:11:41 2007 +0300
@@ -52,8 +52,6 @@ struct mail_index_view {
 	   valid until view is synchronized. */
 	ARRAY_DEFINE(map_refs, struct mail_index_map *);
 
-	struct mail_index_header hdr;
-
 	/* expunge <= head */
 	uint32_t log_file_expunge_seq, log_file_head_seq;
 	uoff_t log_file_expunge_offset, log_file_head_offset;
diff -r eca7e29dce0d -r fd6ff4d9cab1 src/lib-index/mail-index-view-sync.c
--- a/src/lib-index/mail-index-view-sync.c	Sun Jul 01 22:05:09 2007 +0300
+++ b/src/lib-index/mail-index-view-sync.c	Sun Jul 01 22:11:41 2007 +0300
@@ -196,21 +196,6 @@ view_sync_get_expunges(struct mail_index
 	return 0;
 }
 
-#ifdef DEBUG
-static void mail_index_view_check(struct mail_index_view *view)
-{
-	mail_index_map_check(view->map);
-
-	i_assert(view->hdr.messages_count == view->map->hdr.messages_count);
-	i_assert(view->hdr.deleted_messages_count ==
-		 view->map->hdr.deleted_messages_count);
-	i_assert(view->hdr.recent_messages_count ==
-		 view->map->hdr.recent_messages_count);
-	i_assert(view->hdr.seen_messages_count ==
-		 view->map->hdr.seen_messages_count);
-}
-#endif
-
 #define VIEW_IS_SYNCED_TO_SAME(hdr, tail_seq, tail_offset) \
 	((hdr)->log_file_seq == (tail_seq) && \
 	 (hdr)->log_file_head_offset == (tail_offset))
@@ -290,12 +275,11 @@ int mail_index_view_sync_begin(struct ma
 		} else {
 			map = view->map;
 		}
-		view->hdr = map->hdr;
 		i_assert(map->records_count == map->hdr.messages_count);
 	}
 
 #ifdef DEBUG
-	mail_index_view_check(view);
+	mail_index_map_check(view->map);
 #endif
 
 	/* Syncing the view invalidates all previous looked up records.
@@ -608,13 +592,12 @@ void mail_index_view_sync_end(struct mai
 		view->map->hdr.log_file_head_offset = 0;
 		view->map->hdr.log_file_tail_offset = 0;
 	}
-	view->hdr = view->map->hdr;
 
 	mail_index_sync_map_deinit(&ctx->sync_map_ctx);
 	mail_index_view_sync_clean_log_syncs(ctx->view);
 
 #ifdef DEBUG
-	mail_index_view_check(view);
+	mail_index_map_check(view->map);
 #endif
 
 	/* set log view to empty range so unneeded memory gets freed */
diff -r eca7e29dce0d -r fd6ff4d9cab1 src/lib-index/mail-index-view.c
--- a/src/lib-index/mail-index-view.c	Sun Jul 01 22:05:09 2007 +0300
+++ b/src/lib-index/mail-index-view.c	Sun Jul 01 22:11:41 2007 +0300
@@ -22,7 +22,6 @@ void mail_index_view_clone(struct mail_i
 	dest->map = src->map;
 	if (dest->map != NULL)
 		dest->map->refcount++;
-	dest->hdr = src->hdr;
 
 	dest->log_file_expunge_seq = src->log_file_expunge_seq;
 	dest->log_file_expunge_offset = src->log_file_expunge_offset;
@@ -63,11 +62,11 @@ static void mail_index_view_check_nextui
 {
 	struct mail_index_record *rec;
 
-	if (view->hdr.messages_count == 0)
+	if (view->map->hdr.messages_count == 0)
 		return;
 
-	rec = MAIL_INDEX_MAP_IDX(view->map, view->hdr.messages_count-1);
-	i_assert(rec->uid < view->hdr.next_uid);
+	rec = MAIL_INDEX_MAP_IDX(view->map, view->map->hdr.messages_count-1);
+	i_assert(rec->uid < view->map->hdr.next_uid);
 }
 #endif
 
@@ -146,13 +145,13 @@ void mail_index_view_unref_maps(struct m
 
 static uint32_t _view_get_messages_count(struct mail_index_view *view)
 {
-	return view->hdr.messages_count;
+	return view->map->hdr.messages_count;
 }
 
 static const struct mail_index_header *
 _view_get_header(struct mail_index_view *view)
 {
-	return &view->hdr;
+	return &view->map->hdr;
 }
 
 static int _view_lookup_full(struct mail_index_view *view, uint32_t seq,
@@ -243,7 +242,7 @@ static uint32_t mail_index_bsearch_uid(s
 	const struct mail_index_record *rec_base, *rec;
 	uint32_t idx, right_idx, record_size;
 
-	i_assert(view->hdr.messages_count <= view->map->records_count);
+	i_assert(view->map->hdr.messages_count <= view->map->records_count);
 
 	if (uid == 1) {
 		/* optimization: the message can be only the first one */
@@ -253,7 +252,7 @@ static uint32_t mail_index_bsearch_uid(s
 	record_size = view->map->hdr.record_size;
 
 	idx = left_idx;
-	right_idx = view->hdr.messages_count;
+	right_idx = view->map->hdr.messages_count;
 
 	while (left_idx < right_idx) {
 		idx = (left_idx + right_idx) / 2;
@@ -266,14 +265,15 @@ static uint32_t mail_index_bsearch_uid(s
 		else
 			break;
 	}
-	i_assert(idx < view->hdr.messages_count);
+	i_assert(idx < view->map->hdr.messages_count);
 
 	rec = CONST_PTR_OFFSET(rec_base, idx * record_size);
 	if (rec->uid != uid) {
 		if (nearest_side > 0) {
 			/* we want uid or larger */
 			return rec->uid > uid ? idx+1 :
-				idx == view->hdr.messages_count-1 ? 0 : idx+2;
+				(idx == view->map->hdr.messages_count-1 ?
+				 0 : idx+2);
 		} else {
 			/* we want uid or smaller */
 			return rec->uid < uid ? idx + 1 : idx;
@@ -291,7 +291,7 @@ static int _view_lookup_uid_range(struct
 	i_assert(first_uid <= last_uid);
 
 	/* no locking needed for UIDs, see _view_lookup_uid() */
-	if (view->hdr.messages_count == 0) {
+	if (view->map->hdr.messages_count == 0) {
 		*first_seq_r = *last_seq_r = 0;
 		return 0;
 	}
@@ -311,7 +311,7 @@ static int _view_lookup_uid_range(struct
 			return 0;
 		}
 
-		*last_seq_r = view->hdr.messages_count;
+		*last_seq_r = view->map->hdr.messages_count;
 		return 0;
 	}
 
@@ -355,13 +355,13 @@ static int _view_lookup_first(struct mai
 			return 0;
 	}
 
-	i_assert(view->hdr.messages_count <= view->map->records_count);
+	i_assert(view->map->hdr.messages_count <= view->map->records_count);
 
 	/* we can delay locking until we're looking at the flags */
 	if (mail_index_map_lock(view->map) < 0)
 		return -1;
 
-	for (; seq <= view->hdr.messages_count; seq++) {
+	for (; seq <= view->map->hdr.messages_count; seq++) {
 		rec = MAIL_INDEX_MAP_IDX(view->map, seq-1);
 		if ((rec->flags & flags_mask) == (uint8_t)flags) {
 			*seq_r = seq;
@@ -646,8 +646,6 @@ mail_index_view_open_with_map(struct mai
 	view->map = map;
 	view->map->refcount++;
 
-	view->hdr = view->map->hdr;
-
 	view->log_file_expunge_seq = view->log_file_head_seq =
 		view->map->hdr.log_file_seq;
 	view->log_file_expunge_offset = view->log_file_head_offset =


More information about the dovecot-cvs mailing list