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)
--- 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):