Patchwork [2,of,4] revset: prefetch an attribute in _generatorset.__iter__

login
register
mail settings
Submitter Pierre-Yves David
Date Sept. 19, 2014, 8:42 p.m.
Message ID <5923ec85150027d51233.1411159330@marginatus.alto.octopoid.net>
Download mbox | patch
Permalink /patch/5881/
State Superseded
Headers show

Comments

Pierre-Yves David - Sept. 19, 2014, 8:42 p.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@fb.com>
# Date 1411080765 25200
#      Thu Sep 18 15:52:45 2014 -0700
# Node ID 5923ec85150027d51233f04ecc2b59bfa69d2a40
# Parent  a38a9240a0c57afe2f4939f41a63382ef76b92fc
revset: prefetch an attribute in _generatorset.__iter__

Python's attribute lookup are expensible, lets do less of them.

Patch

diff --git a/mercurial/revset.py b/mercurial/revset.py
--- a/mercurial/revset.py
+++ b/mercurial/revset.py
@@ -2655,16 +2655,16 @@  class _generatorset(object):
         #
         # Getting ride of it would provide an about 15% speed up on this
         # iteration.
         i = 0
         genlist = self._genlist
-        consume = self._consumegen()
+        nextrev = self._consumegen().next
         while True:
             if i < len(genlist):
                 yield genlist[i]
             else:
-                yield consume.next()
+                yield nextrev()
             i += 1
 
     def _consumegen(self):
         for item in self._gen:
             self._cache[item] = True