[Zope-Checkins] CVS: Zope/lib/python/Products/PluginIndexes/TextIndex - GlobbingLexicon.py:1.14

Andreas Jung andreas@digicool.com
Thu, 18 Apr 2002 13:10:35 -0400


Update of /cvs-repository/Zope/lib/python/Products/PluginIndexes/TextIndex
In directory cvs.zope.org:/tmp/cvs-serv30675/Products/PluginIndexes/TextIndex

Modified Files:
	GlobbingLexicon.py 
Log Message:
optimized the code to create digrams (10% performance gain)


=== Zope/lib/python/Products/PluginIndexes/TextIndex/GlobbingLexicon.py 1.13 => 1.14 ===
     def createDigrams(self, word):
         """Returns a list with the set of digrams in the word."""
-        digrams = list(word)
-        digrams.append(self.eow)
-        last = self.eow
-
-        for i in range(len(digrams)):
-            last, digrams[i] = digrams[i], last + digrams[i]
-
-        return digrams
+        
+        word = '$'+word+'$'
+        return [ word[i:i+2] for i in range(len(word)-1)]
 
     
     def getWordId(self, word):