changeset 22528:b6dc3b79bb25

revset: avoid in loop lookup in _generatorset._consumegen Python lookups are slow, so do all lookup outside of the for loop. This provide a small but still significant speedup: revset #0: 0:: 0) wall 0.063258 comb 0.060000 user 0.060000 sys 0.000000 (best of 100) 1) wall 0.057776 comb 0.050000 user 0.050000 sys 0.000000 (best of 100)
author Pierre-Yves David <pierre-yves.david@fb.com>
date Wed, 30 Apr 2014 16:56:48 -0700
parents 6e38b5d49977
children 5c53d7888aef
files mercurial/revset.py
diffstat 1 files changed, 4 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/revset.py	Fri Apr 25 14:51:24 2014 -0700
+++ b/mercurial/revset.py	Wed Apr 30 16:56:48 2014 -0700
@@ -2672,9 +2672,11 @@
             i += 1
 
     def _consumegen(self):
+        cache = self._cache
+        genlist = self._genlist.append
         for item in self._gen:
-            self._cache[item] = True
-            self._genlist.append(item)
+            cache[item] = True
+            genlist(item)
             yield item
         self._finished = True