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

login
register
mail settings
Submitter Pierre-Yves David
Date May 1, 2014, 7:20 p.m.
Message ID <c753a48e8bf3557856fb.1398972025@marginatus.alto.octopoid.net>
Download mbox | patch
Permalink /patch/4463/
State Superseded
Commit 0952904dc1e5fbd2632fdd577712ffde075b8d3b
Headers show

Comments

Pierre-Yves David - May 1, 2014, 7:20 p.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@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)

Patch

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