dovecot-2.2: fts-lucene: Removed lazy initialization code.

dovecot at dovecot.org dovecot at dovecot.org
Tue May 5 13:20:25 UTC 2015


details:   http://hg.dovecot.org/dovecot-2.2/rev/25f29613908f
changeset: 18524:25f29613908f
user:      Timo Sirainen <tss at iki.fi>
date:      Tue May 05 16:18:21 2015 +0300
description:
fts-lucene: Removed lazy initialization code.
This is no longer needed after the previous fts commit.

diffstat:

 src/plugins/fts-lucene/fts-backend-lucene.c |  49 +++++++---------------------
 1 files changed, 13 insertions(+), 36 deletions(-)

diffs (113 lines):

diff -r eee937dc9438 -r 25f29613908f src/plugins/fts-lucene/fts-backend-lucene.c
--- a/src/plugins/fts-lucene/fts-backend-lucene.c	Tue May 05 16:17:14 2015 +0300
+++ b/src/plugins/fts-lucene/fts-backend-lucene.c	Tue May 05 16:18:21 2015 +0300
@@ -126,35 +126,14 @@
 	return &backend->backend;
 }
 
-static void fts_backend_lucene_real_init(struct lucene_fts_backend *backend)
-{
-	struct fts_lucene_user *fuser =
-		FTS_LUCENE_USER_CONTEXT(backend->backend.ns->user);
-	const char *path;
-
-	if (backend->index != NULL)
-		return;
-
-	/* initialize this path lazily, because with mbox format the get_path()
-	   is overridden by the mbox code, but it hasn't had a chance to do
-	   that yet in fts_backend_lucene_init(). */
-	path = mailbox_list_get_root_forced(backend->backend.ns->list,
-					    MAILBOX_LIST_PATH_TYPE_INDEX);
-
-	backend->dir_path = i_strconcat(path, "/"LUCENE_INDEX_DIR_NAME, NULL);
-	backend->index = lucene_index_init(backend->dir_path,
-					   backend->backend.ns->list,
-					   &fuser->set);
-
-	path = t_strconcat(backend->dir_path, "/"LUCENE_EXPUNGE_LOG_NAME, NULL);
-	backend->expunge_log = fts_expunge_log_init(path);
-}
-
 static int
 fts_backend_lucene_init(struct fts_backend *_backend, const char **error_r)
 {
+	struct lucene_fts_backend *backend =
+		(struct lucene_fts_backend *)_backend;
 	struct fts_lucene_user *fuser =
 		FTS_LUCENE_USER_CONTEXT(_backend->ns->user);
+	const char *path;
 
 	if (fuser == NULL) {
 		/* invalid settings */
@@ -168,6 +147,16 @@
 		_backend->flags &= ~FTS_BACKEND_FLAG_FUZZY_SEARCH;
 		_backend->flags |= FTS_BACKEND_FLAG_TOKENIZED_INPUT;
 	}
+	path = mailbox_list_get_root_forced(_backend->ns->list,
+					    MAILBOX_LIST_PATH_TYPE_INDEX);
+
+	backend->dir_path = i_strconcat(path, "/"LUCENE_INDEX_DIR_NAME, NULL);
+	backend->index = lucene_index_init(backend->dir_path,
+					   _backend->ns->list,
+					   &fuser->set);
+
+	path = t_strconcat(backend->dir_path, "/"LUCENE_EXPUNGE_LOG_NAME, NULL);
+	backend->expunge_log = fts_expunge_log_init(path);
 	return 0;
 }
 
@@ -195,8 +184,6 @@
 	struct fts_index_header hdr;
 	uint32_t set_checksum;
 
-	fts_backend_lucene_real_init(backend);
-
 	if (fts_index_get_header(box, &hdr)) {
 		set_checksum = fts_lucene_settings_checksum(&fuser->set);
 		if (!fts_index_have_compatible_settings(_backend->ns->list,
@@ -231,8 +218,6 @@
 
 	i_assert(!backend->updating);
 
-	fts_backend_lucene_real_init(backend);
-
 	ctx = i_new(struct lucene_fts_backend_update_context, 1);
 	ctx->ctx.backend = _backend;
 	ctx->mime_parts = fuser->set.mime_parts;
@@ -468,8 +453,6 @@
 	struct lucene_fts_backend *backend =
 		(struct lucene_fts_backend *)_backend;
 
-	fts_backend_lucene_real_init(backend);
-
 	if (lucene_index_rescan(backend->index) < 0)
 		return -1;
 	return lucene_index_optimize(backend->index);
@@ -481,8 +464,6 @@
 		(struct lucene_fts_backend *)_backend;
 	int ret;
 
-	fts_backend_lucene_real_init(backend);
-
 	ret = lucene_index_expunge_from_log(backend->index,
 					    backend->expunge_log);
 	if (ret == 0) {
@@ -504,8 +485,6 @@
 		(struct lucene_fts_backend *)_backend;
 	int ret;
 
-	fts_backend_lucene_real_init(backend);
-
 	if (fts_backend_select(backend, box) < 0)
 		return -1;
 	T_BEGIN {
@@ -578,8 +557,6 @@
 		(struct lucene_fts_backend *)_backend;
 	int ret;
 
-	fts_backend_lucene_real_init(backend);
-
 	T_BEGIN {
 		HASH_TABLE_TYPE(wguid_result) guids;
 


More information about the dovecot-cvs mailing list