[PATCH 1 of 2 stable] lazyset: directly use __contains__ instead of a lambda

pierre-yves.david at ens-lyon.org pierre-yves.david at ens-lyon.org
Thu May 1 14:20:25 CDT 2014


# HG changeset patch
# User Pierre-Yves David <pierre-yves.david at fb.com>
# Date 1398971700 25200
#      Thu May 01 12:15:00 2014 -0700
# Branch stable
# Node ID c753a48e8bf3557856fb34e34daa49c7fa61b9c3
# Parent  799c494189a9db994cd6ce7fd924e9825b3fe425
lazyset: directly use __contains__ instead of a lambda

We apply the same speedup as in spanset, getting rid of the useless lambda.
(No new timing, as this is the very same change)

diff --git a/mercurial/revset.py b/mercurial/revset.py
--- a/mercurial/revset.py
+++ b/mercurial/revset.py
@@ -2354,11 +2354,11 @@ class lazyset(object):
         for x in self._subset:
             if cond(x):
                 yield x
 
     def __and__(self, x):
-        return lazyset(self, lambda r: r in x)
+        return lazyset(self, x.__contains__)
 
     def __sub__(self, x):
         return lazyset(self, lambda r: r not in x)
 
     def __add__(self, x):


More information about the Mercurial-devel mailing list