[Commits] [SCM] claws branch, master, updated. 3.17.0-82-gb20a6fa
Colin
colin at claws-mail.org
Sat Oct 6 11:27:25 CEST 2018
The branch, master has been updated
via b20a6fa6d4a20ecc94bb6ad417a2b7ab08f98ed1 (commit)
from 618839aae3e97e0869fcc2c9b2b25f86995877b0 (commit)
Summary of changes:
src/matcher.c | 12 +++++++++---
src/matcher.h | 5 ++++-
2 files changed, 13 insertions(+), 4 deletions(-)
- Log -----------------------------------------------------------------
commit b20a6fa6d4a20ecc94bb6ad417a2b7ab08f98ed1
Author: Colin Leroy <colin at colino.net>
Date: Sat Oct 6 11:26:53 2018 +0200
Halve the time spent manipulating case in case-insensitive searches
diff --git a/src/matcher.c b/src/matcher.c
index 29581e9..4a0392d 100644
--- a/src/matcher.c
+++ b/src/matcher.c
@@ -324,6 +324,7 @@ MatcherProp *matcherprop_new(gint criteria, const gchar *header,
#ifndef G_OS_WIN32
prop->preg = NULL;
#endif
+ prop->casefold_expr = NULL;
prop->value = value;
prop->error = 0;
@@ -345,6 +346,7 @@ void matcherprop_free(MatcherProp *prop)
regfree(prop->preg);
g_free(prop->preg);
}
+ g_free(prop->casefold_expr);
#endif
g_free(prop);
}
@@ -368,6 +370,7 @@ MatcherProp *matcherprop_copy(const MatcherProp *src)
#ifndef G_OS_WIN32
prop->preg = NULL; /* will be re-evaluated */
#endif
+ prop->casefold_expr = src->casefold_expr ? g_strdup(src->casefold_expr) : NULL;
prop->value = src->value;
prop->error = src->error;
return prop;
@@ -475,7 +478,7 @@ static gboolean matcherprop_string_match(MatcherProp *prop, const gchar *str,
const gchar *debug_context)
{
gchar *str1;
- gchar *down_expr;
+ const gchar *down_expr;
gboolean ret = FALSE;
gboolean should_free = FALSE;
if (str == NULL)
@@ -484,7 +487,11 @@ static gboolean matcherprop_string_match(MatcherProp *prop, const gchar *str,
if (prop->matchtype == MATCHTYPE_REGEXPCASE ||
prop->matchtype == MATCHTYPE_MATCHCASE) {
str1 = g_utf8_casefold(str, -1);
- down_expr = g_utf8_casefold(prop->expr, -1);
+ if (!prop->casefold_expr) {
+ prop->casefold_expr = g_utf8_casefold(prop->expr, -1);
+ }
+ down_expr = prop->casefold_expr;
+
should_free = TRUE;
} else {
str1 = (gchar *)str;
@@ -569,7 +576,6 @@ static gboolean matcherprop_string_match(MatcherProp *prop, const gchar *str,
free_strs:
if (should_free) {
g_free(str1);
- g_free(down_expr);
}
return ret;
}
diff --git a/src/matcher.h b/src/matcher.h
index 392924d..6b6fbbe 100644
--- a/src/matcher.h
+++ b/src/matcher.h
@@ -36,10 +36,13 @@ struct _MatcherProp {
gchar *header;
gchar *expr;
int value;
- regex_t *preg;
int error;
gboolean result;
gboolean done;
+ /* Allows recompiling expr each time */
+ regex_t *preg;
+ /* Allows casefolding expr each time */
+ gchar *casefold_expr;
};
struct _MatcherList {
-----------------------------------------------------------------------
hooks/post-receive
--
Claws Mail
More information about the Commits
mailing list