[Zope-Checkins] CVS: Zope/lib/python/Products/PluginIndexes/TextIndex/Splitter/ISO_8859_1_Splitter/src - ISO_8859_1_Splitter.c:1.5.10.1

Andreas Jung andreas@zope.com
Mon, 7 Jan 2002 19:48:28 -0500


Update of /cvs-repository/Zope/lib/python/Products/PluginIndexes/TextIndex/Splitter/ISO_8859_1_Splitter/src
In directory cvs.zope.org:/tmp/cvs-serv1429/src

Modified Files:
      Tag: ajung-textindexng-branch
	ISO_8859_1_Splitter.c 
Log Message:
added split() function making the splitter up to 50% faster


=== Zope/lib/python/Products/PluginIndexes/TextIndex/Splitter/ISO_8859_1_Splitter/src/ISO_8859_1_Splitter.c 1.5 => 1.5.10.1 ===
 }
 
+
+static PyObject *
+Splitter_split(Splitter*self)
+{
+    PyObject *list=NULL,*word=NULL;
+
+    UNLESS(list = PyList_New(0)) return NULL;
+
+    Splitter_reset(self);
+
+    while (1) {
+        Py_XDECREF(word);
+
+        UNLESS(word = next_word(self,NULL,NULL)) return NULL;
+
+        if (word == Py_None) {
+            return list;
+        }
+
+        PyList_Append(list,word);
+    }
+
+    return list;
+}
+
+
 static PyObject *
 Splitter_concat(Splitter *self, PyObject *other)
 {
@@ -416,6 +442,9 @@
 
 static struct PyMethodDef Splitter_methods[] =
     {
+        { "split", (PyCFunction)Splitter_split, 0,
+            "split() -- Split the string in one run"
+        },
         { "pos", (PyCFunction)Splitter_pos, 0,
             "pos(index) -- Return the starting and ending position of a token"
         },