changeset 22669:00c8abe64cf3

revset: prefetch an attribute in _generatorset.__iter__ Python's attribute lookup are expensible, lets do less of them. This gives us a 7% speedup on this revset iteration (from 0.063403 to 0.059032)
author Pierre-Yves David <pierre-yves.david@fb.com>
date Thu, 18 Sep 2014 15:52:45 -0700
parents 13e3f07d74a3
children 44dce874de97
files mercurial/revset.py
diffstat 1 files changed, 4 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/revset.py	Tue Sep 09 22:14:13 2014 +0900
+++ b/mercurial/revset.py	Thu Sep 18 15:52:45 2014 -0700
@@ -2667,12 +2667,13 @@
         # iteration.
         i = 0
         genlist = self._genlist
-        consume = self._consumegen()
+        nextrev = self._consumegen().next
+        _len = len # cache global lookup
         while True:
-            if i < len(genlist):
+            if i < _len(genlist):
                 yield genlist[i]
             else:
-                yield consume.next()
+                yield nextrev()
             i += 1
 
     def _consumegen(self):