Patchwork [4,of,4] revset: avoid in loop lookup in _generatorset._consumegen

login
register
mail settings
Submitter Pierre-Yves David
Date Sept. 19, 2014, 8:42 p.m.
Message ID <c3994139db249abe184d.1411159332@marginatus.alto.octopoid.net>
Download mbox | patch
Permalink /patch/5883/
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 1398902208 25200
#      Wed Apr 30 16:56:48 2014 -0700
# Node ID c3994139db249abe184d91b90fda9b4c8c8f67d1
# Parent  e3e71e54d41fc10e5cd95fe0ea6f3c471c09ca67
revset: avoid in loop lookup in _generatorset._consumegen

Python lookup are slow, let do all lookup outside of the for loop.

Patch

diff --git a/mercurial/revset.py b/mercurial/revset.py
--- a/mercurial/revset.py
+++ b/mercurial/revset.py
@@ -2664,13 +2664,15 @@  class _generatorset(object):
                     yield nextrev()
                 i += 1
         return gen()
 
     def _consumegen(self):
+        cache = self._cache.__setitem__
+        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
 
     def set(self):
         return self