[Zope-CVS] CVS: Products/ZCTextIndex - Lexicon.py:

Jeremy Hylton jeremy@zope.com
Tue, 14 May 2002 01:00:31 -0400

Update of /cvs-repository/Products/ZCTextIndex
In directory cvs.zope.org:/tmp/cvs-serv13478

Modified Files:
      Tag: TextIndexDS9-branch
Log Message:
Replace a for loop with a map. 
Profiling suggests that this is a crucial hotspot in the indexing process, 
as the for loop iterates over every word in every document.  The change 
is so simple it doesn't even feel premature. 
map has got to be a win if only because of the number of SET_LINENOs  

=== Products/ZCTextIndex/Lexicon.py => ===
         for element in self.__pipeline:
             last = element.process(last)
-        wids = []
-        for word in last:
-            wids.append(self._getWordIdCreate(word))
-        return wids
+        return map(self._getWordIdCreate, last)
     def termToWordIds(self, text):
         last = _text2list(text)