dovecot-2.2: lib-fts: fts-filter API changed to have a non-point...

dovecot at dovecot.org dovecot at dovecot.org
Tue Jun 2 22:07:17 UTC 2015


details:   http://hg.dovecot.org/dovecot-2.2/rev/11c181d51b54
changeset: 18815:11c181d51b54
user:      Timo Sirainen <tss at iki.fi>
date:      Wed Jun 03 00:46:23 2015 +0300
description:
lib-fts: fts-filter API changed to have a non-pointer vfuncs variable.
The main benefit being that the fts-filter implementations can save a few
lines of code.

diffstat:

 src/lib-fts/fts-filter-lowercase.c        |  12 +++++-------
 src/lib-fts/fts-filter-normalizer-icu.c   |  12 +++++-------
 src/lib-fts/fts-filter-private.h          |   2 +-
 src/lib-fts/fts-filter-stemmer-snowball.c |  11 +++++------
 src/lib-fts/fts-filter-stopwords.c        |  12 +++++-------
 src/lib-fts/fts-filter.c                  |  10 +++++-----
 6 files changed, 26 insertions(+), 33 deletions(-)

diffs (141 lines):

diff -r 932a0a83514b -r 11c181d51b54 src/lib-fts/fts-filter-lowercase.c
--- a/src/lib-fts/fts-filter-lowercase.c	Wed Jun 03 00:43:51 2015 +0300
+++ b/src/lib-fts/fts-filter-lowercase.c	Wed Jun 03 00:46:23 2015 +0300
@@ -44,15 +44,13 @@
 	return 1;
 }
 
-static const struct fts_filter_vfuncs lowercase_filter_vfuncs = {
-	fts_filter_lowercase_create,
-	fts_filter_lowercase_filter,
-	NULL
-};
-
 static const struct fts_filter fts_filter_lowercase_real = {
 	.class_name = "lowercase",
-	.v = &lowercase_filter_vfuncs
+	.v = {
+		fts_filter_lowercase_create,
+		fts_filter_lowercase_filter,
+		NULL
+	}
 };
 
 const struct fts_filter *fts_filter_lowercase = &fts_filter_lowercase_real;
diff -r 932a0a83514b -r 11c181d51b54 src/lib-fts/fts-filter-normalizer-icu.c
--- a/src/lib-fts/fts-filter-normalizer-icu.c	Wed Jun 03 00:43:51 2015 +0300
+++ b/src/lib-fts/fts-filter-normalizer-icu.c	Wed Jun 03 00:46:23 2015 +0300
@@ -156,15 +156,13 @@
 
 #endif
 
-static const struct fts_filter_vfuncs normalizer_filter_vfuncs = {
-	fts_filter_normalizer_icu_create,
-	fts_filter_normalizer_icu_filter,
-	fts_filter_normalizer_icu_destroy
-};
-
 static const struct fts_filter fts_filter_normalizer_icu_real = {
 	.class_name = "normalizer-icu",
-	.v = &normalizer_filter_vfuncs
+	.v = {
+		fts_filter_normalizer_icu_create,
+		fts_filter_normalizer_icu_filter,
+		fts_filter_normalizer_icu_destroy
+	}
 };
 
 const struct fts_filter *fts_filter_normalizer_icu =
diff -r 932a0a83514b -r 11c181d51b54 src/lib-fts/fts-filter-private.h
--- a/src/lib-fts/fts-filter-private.h	Wed Jun 03 00:43:51 2015 +0300
+++ b/src/lib-fts/fts-filter-private.h	Wed Jun 03 00:46:23 2015 +0300
@@ -25,7 +25,7 @@
 
 struct fts_filter {
 	const char *class_name; /* name of the class this is based on */
-	const struct fts_filter_vfuncs *v;
+	struct fts_filter_vfuncs v;
 	int refcount;
 	struct fts_filter *parent;
 	string_t *token;
diff -r 932a0a83514b -r 11c181d51b54 src/lib-fts/fts-filter-stemmer-snowball.c
--- a/src/lib-fts/fts-filter-stemmer-snowball.c	Wed Jun 03 00:43:51 2015 +0300
+++ b/src/lib-fts/fts-filter-stemmer-snowball.c	Wed Jun 03 00:46:23 2015 +0300
@@ -116,15 +116,14 @@
 }
 
 #endif
-static const struct fts_filter_vfuncs snowball_stemmer_filter_vfuncs = {
-	fts_filter_stemmer_snowball_create,
-	fts_filter_stemmer_snowball_filter,
-	fts_filter_stemmer_snowball_destroy
-};
 
 static const struct fts_filter fts_filter_stemmer_snowball_real = {
 	.class_name = "snowball",
-	.v = &snowball_stemmer_filter_vfuncs
+	.v = {
+		fts_filter_stemmer_snowball_create,
+		fts_filter_stemmer_snowball_filter,
+		fts_filter_stemmer_snowball_destroy
+	}
 };
 
 const struct fts_filter *fts_filter_stemmer_snowball = &fts_filter_stemmer_snowball_real;
diff -r 932a0a83514b -r 11c181d51b54 src/lib-fts/fts-filter-stopwords.c
--- a/src/lib-fts/fts-filter-stopwords.c	Wed Jun 03 00:43:51 2015 +0300
+++ b/src/lib-fts/fts-filter-stopwords.c	Wed Jun 03 00:46:23 2015 +0300
@@ -113,14 +113,12 @@
 	return hash_table_lookup(sp->stopwords, *token) == NULL ? 1 : 0;
 }
 
-const struct fts_filter_vfuncs stopwords_filter_vfuncs = {
-	fts_filter_stopwords_create,
-	fts_filter_stopwords_filter,
-	fts_filter_stopwords_destroy
-};
-
 const struct fts_filter fts_filter_stopwords_real = {
 	.class_name = "stopwords",
-	.v = &stopwords_filter_vfuncs
+	.v = {
+		fts_filter_stopwords_create,
+		fts_filter_stopwords_filter,
+		fts_filter_stopwords_destroy
+	}
 };
 const struct fts_filter *fts_filter_stopwords = &fts_filter_stopwords_real;
diff -r 932a0a83514b -r 11c181d51b54 src/lib-fts/fts-filter.c
--- a/src/lib-fts/fts-filter.c	Wed Jun 03 00:43:51 2015 +0300
+++ b/src/lib-fts/fts-filter.c	Wed Jun 03 00:46:23 2015 +0300
@@ -63,8 +63,8 @@
 	if (settings == NULL)
 		settings = &empty_settings;
 
-	if (filter_class->v->create != NULL) {
-		if (filter_class->v->create(lang, settings, &fp, error_r) < 0) {
+	if (filter_class->v.create != NULL) {
+		if (filter_class->v.create(lang, settings, &fp, error_r) < 0) {
 			*filter_r = NULL;
 			return -1;
 		}
@@ -104,8 +104,8 @@
 
 	if (fp->parent != NULL)
 		fts_filter_unref(&fp->parent);
-	if (fp->v->destroy != NULL)
-		fp->v->destroy(fp);
+	if (fp->v.destroy != NULL)
+		fp->v.destroy(fp);
 	else {
 		/* default destroy implementation */
 		if (fp->token != NULL)
@@ -127,7 +127,7 @@
 
 	/* Parent returned token or no parent. */
 	if (ret > 0 || filter->parent == NULL)
-		ret = filter->v->filter(filter, token, error_r);
+		ret = filter->v.filter(filter, token, error_r);
 
 	if (ret <= 0)
 		*token = NULL;


More information about the dovecot-cvs mailing list