From: Alfons Hoogervorst Date: Fri, 27 Dec 2002 22:56:17 +0000 (+0000) Subject: re-organize matcher part 5; more to come X-Git-Tag: rel_0_8_9~149 X-Git-Url: http://git.claws-mail.org/?p=claws.git;a=commitdiff_plain;h=5768e656c37b256c9cbffdbfbaea54bc8b77b194 re-organize matcher part 5; more to come * src/matcher.c hash keywords in matchparser_tab --- diff --git a/ChangeLog.claws b/ChangeLog.claws index da6479937..99c86a975 100644 --- a/ChangeLog.claws +++ b/ChangeLog.claws @@ -1,3 +1,10 @@ +2002-12-27 [alfons] 0.8.8claws17 + + re-organize matcher part 5; more to come + + * src/matcher.c + hash keywords in matchparser_tab + 2002-12-27 [alfons] 0.8.8claws16 re-organize matcher part 4; more to come diff --git a/configure.in b/configure.in index 58dde4298..580f180c7 100644 --- a/configure.in +++ b/configure.in @@ -11,7 +11,7 @@ MINOR_VERSION=8 MICRO_VERSION=8 INTERFACE_AGE=0 BINARY_AGE=0 -EXTRA_VERSION=claws16 +EXTRA_VERSION=claws17 VERSION=$MAJOR_VERSION.$MINOR_VERSION.$MICRO_VERSION$EXTRA_VERSION dnl set $target diff --git a/src/matcher.c b/src/matcher.c index 0f6c0968c..47eadcf2c 100644 --- a/src/matcher.c +++ b/src/matcher.c @@ -118,9 +118,11 @@ static MatchParser matchparser_tab[] = { {MATCHACTION_DELETE_ON_SERVER, "delete_on_server"} }; +static GHashTable *matchparser_hashtab; + /* get_matchparser_tab_str() - used by filtering.c to translate * actions to debug strings */ -gchar * get_matchparser_tab_str(gint id) +gchar *get_matchparser_tab_str(gint id) { gint i; @@ -131,18 +133,27 @@ gchar * get_matchparser_tab_str(gint id) return NULL; } +static void create_matchparser_hashtab(void) +{ + int i; + + if (matchparser_hashtab) return; + matchparser_hashtab = g_hash_table_new(g_str_hash, g_str_equal); + for (i = 0; i < sizeof matchparser_tab / sizeof matchparser_tab[0]; i++) + g_hash_table_insert(matchparser_hashtab, + matchparser_tab[i].str, + &matchparser_tab[i]); +} + gint get_matchparser_tab_id(const gchar *str) { gint i; + MatchParser *res; - /* - * begs for a hash table - */ - for (i = 0; i < sizeof matchparser_tab / sizeof matchparser_tab[0]; i++) { - if (g_strcasecmp(matchparser_tab[i].str, str) == 0) - return matchparser_tab[i].id; - } - return -1; + if (NULL != (res = g_hash_table_lookup(matchparser_hashtab, str))) { + return res->id; + } else + return -1; } /* matcher_escape_str() - escapes a string returns newly allocated escaped string */ @@ -1290,6 +1301,7 @@ void prefs_matcher_read_config(void) gchar *rcpath; FILE *f; + create_matchparser_hashtab(); prefs_scoring_clear(); prefs_filtering_clear();