dovecot-2.2: lib-fts: Store pointers to fts_tokenizer classes in...

dovecot at dovecot.org dovecot at dovecot.org
Sat May 9 12:00:26 UTC 2015


details:   http://hg.dovecot.org/dovecot-2.2/rev/5937f4d505c5
changeset: 18589:5937f4d505c5
user:      Timo Sirainen <tss at iki.fi>
date:      Sat May 09 14:55:47 2015 +0300
description:
lib-fts: Store pointers to fts_tokenizer classes instead of copying the data.
The same reason as for doing this for fts-filter.

diffstat:

 src/lib-fts/fts-tokenizer.c |  14 +++++++-------
 1 files changed, 7 insertions(+), 7 deletions(-)

diffs (48 lines):

diff -r cd376c0ac132 -r 5937f4d505c5 src/lib-fts/fts-tokenizer.c
--- a/src/lib-fts/fts-tokenizer.c	Sat May 09 14:53:46 2015 +0300
+++ b/src/lib-fts/fts-tokenizer.c	Sat May 09 14:55:47 2015 +0300
@@ -8,7 +8,7 @@
 #include "fts-tokenizer.h"
 #include "fts-tokenizer-private.h"
 
-ARRAY(struct fts_tokenizer) fts_tokenizer_classes;
+static ARRAY(const struct fts_tokenizer *) fts_tokenizer_classes;
 
 void fts_tokenizers_init(void)
 {
@@ -29,17 +29,17 @@
 {
 	if (!array_is_created(&fts_tokenizer_classes))
 		i_array_init(&fts_tokenizer_classes, FTS_TOKENIZER_CLASSES_NR);
-	array_append(&fts_tokenizer_classes, tok_class, 1);
+	array_append(&fts_tokenizer_classes, &tok_class, 1);
 }
 
 /* private */
 void fts_tokenizer_unregister(const struct fts_tokenizer *tok_class)
 {
-	const struct fts_tokenizer *tp;
+	const struct fts_tokenizer *const *tp;
 	unsigned int idx;
 
 	array_foreach(&fts_tokenizer_classes, tp) {
-		if (strcmp(tp->name, tok_class->name) == 0) {
+		if (strcmp((*tp)->name, tok_class->name) == 0) {
 			idx = array_foreach_idx(&fts_tokenizer_classes, tp);
 			array_delete(&fts_tokenizer_classes, idx, 1);
 			if (array_count(&fts_tokenizer_classes) == 0)
@@ -52,11 +52,11 @@
 
 const struct fts_tokenizer *fts_tokenizer_find(const char *name)
 {
-	const struct fts_tokenizer *tp;
+	const struct fts_tokenizer *const *tp;
 
 	array_foreach(&fts_tokenizer_classes, tp) {
-		if (strcmp(tp->name, name) == 0)
-			return tp;
+		if (strcmp((*tp)->name, name) == 0)
+			return *tp;
 	}
 	return NULL;
 }


More information about the dovecot-cvs mailing list