lucy-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nwelln...@apache.org
Subject [lucy-commits] [24/24] git commit: refs/heads/cfish-string-prep1 - Eliminate Str_Cat_Char in SnowballStopFilter
Date Sun, 01 Sep 2013 20:17:12 GMT
Eliminate Str_Cat_Char in SnowballStopFilter


Project: http://git-wip-us.apache.org/repos/asf/lucy/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucy/commit/ab8d0669
Tree: http://git-wip-us.apache.org/repos/asf/lucy/tree/ab8d0669
Diff: http://git-wip-us.apache.org/repos/asf/lucy/diff/ab8d0669

Branch: refs/heads/cfish-string-prep1
Commit: ab8d0669a449bf74ead1c639785ace87d614e304
Parents: 31ae352
Author: Nick Wellnhofer <wellnhofer@aevum.de>
Authored: Sun Sep 1 19:26:12 2013 +0200
Committer: Nick Wellnhofer <wellnhofer@aevum.de>
Committed: Sun Sep 1 22:05:03 2013 +0200

----------------------------------------------------------------------
 core/Lucy/Analysis/SnowballStopFilter.c | 34 +++++++++++++---------------
 1 file changed, 16 insertions(+), 18 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucy/blob/ab8d0669/core/Lucy/Analysis/SnowballStopFilter.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Analysis/SnowballStopFilter.c b/core/Lucy/Analysis/SnowballStopFilter.c
index c6ffb97..323c108 100644
--- a/core/Lucy/Analysis/SnowballStopFilter.c
+++ b/core/Lucy/Analysis/SnowballStopFilter.c
@@ -119,25 +119,24 @@ SnowStop_Load_IMP(SnowballStopFilter *self, Obj *dump) {
 
 Hash*
 SnowStop_gen_stoplist(const String *language) {
-    String *lang = Str_new(3);
-    Str_Cat_Char(lang, tolower(Str_Code_Point_At(language, 0)));
-    Str_Cat_Char(lang, tolower(Str_Code_Point_At(language, 1)));
+    char lang[2];
+    lang[0] = tolower(Str_Code_Point_At(language, 0));
+    lang[1] = tolower(Str_Code_Point_At(language, 1));
     const uint8_t **words = NULL;
-    if (Str_Equals_Str(lang, "da", 2))      { words = SnowStop_snow_da; }
-    else if (Str_Equals_Str(lang, "de", 2)) { words = SnowStop_snow_de; }
-    else if (Str_Equals_Str(lang, "en", 2)) { words = SnowStop_snow_en; }
-    else if (Str_Equals_Str(lang, "es", 2)) { words = SnowStop_snow_es; }
-    else if (Str_Equals_Str(lang, "fi", 2)) { words = SnowStop_snow_fi; }
-    else if (Str_Equals_Str(lang, "fr", 2)) { words = SnowStop_snow_fr; }
-    else if (Str_Equals_Str(lang, "hu", 2)) { words = SnowStop_snow_hu; }
-    else if (Str_Equals_Str(lang, "it", 2)) { words = SnowStop_snow_it; }
-    else if (Str_Equals_Str(lang, "nl", 2)) { words = SnowStop_snow_nl; }
-    else if (Str_Equals_Str(lang, "no", 2)) { words = SnowStop_snow_no; }
-    else if (Str_Equals_Str(lang, "pt", 2)) { words = SnowStop_snow_pt; }
-    else if (Str_Equals_Str(lang, "ru", 2)) { words = SnowStop_snow_ru; }
-    else if (Str_Equals_Str(lang, "sv", 2)) { words = SnowStop_snow_sv; }
+    if (memcmp(lang, "da", 2) == 0)      { words = SnowStop_snow_da; }
+    else if (memcmp(lang, "de", 2) == 0) { words = SnowStop_snow_de; }
+    else if (memcmp(lang, "en", 2) == 0) { words = SnowStop_snow_en; }
+    else if (memcmp(lang, "es", 2) == 0) { words = SnowStop_snow_es; }
+    else if (memcmp(lang, "fi", 2) == 0) { words = SnowStop_snow_fi; }
+    else if (memcmp(lang, "fr", 2) == 0) { words = SnowStop_snow_fr; }
+    else if (memcmp(lang, "hu", 2) == 0) { words = SnowStop_snow_hu; }
+    else if (memcmp(lang, "it", 2) == 0) { words = SnowStop_snow_it; }
+    else if (memcmp(lang, "nl", 2) == 0) { words = SnowStop_snow_nl; }
+    else if (memcmp(lang, "no", 2) == 0) { words = SnowStop_snow_no; }
+    else if (memcmp(lang, "pt", 2) == 0) { words = SnowStop_snow_pt; }
+    else if (memcmp(lang, "ru", 2) == 0) { words = SnowStop_snow_ru; }
+    else if (memcmp(lang, "sv", 2) == 0) { words = SnowStop_snow_sv; }
     else {
-        DECREF(lang);
         return NULL;
     }
     size_t num_stopwords = 0;
@@ -149,7 +148,6 @@ SnowStop_gen_stoplist(const String *language) {
         NoCloneHash_Store(stoplist, (Obj*)stop, (Obj*)Str_newf(""));
         DECREF(stop);
     }
-    DECREF(lang);
     return (Hash*)stoplist;
 }
 


Mime
View raw message