Patchwork [2,of,2,stable] orderedlazyset: 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 <f7c5fe7a29485ec20d41.1398972026@marginatus.alto.octopoid.net>
Download mbox | patch
Permalink /patch/4464/
State Accepted
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 1398971728 25200
#      Thu May 01 12:15:28 2014 -0700
# Branch stable
# Node ID f7c5fe7a29485ec20d41d7e00020102a0d84840c
# Parent  c753a48e8bf3557856fb34e34daa49c7fa61b9c3
orderedlazyset: 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)
Matt Mackall - May 1, 2014, 8:34 p.m.
On Thu, 2014-05-01 at 12:20 -0700, pierre-yves.david@ens-lyon.org wrote:
> # HG changeset patch
> # User Pierre-Yves David <pierre-yves.david@fb.com>
> # Date 1398971728 25200
> #      Thu May 01 12:15:28 2014 -0700
> # Branch stable
> # Node ID f7c5fe7a29485ec20d41d7e00020102a0d84840c
> # Parent  c753a48e8bf3557856fb34e34daa49c7fa61b9c3
> orderedlazyset: directly use __contains__ instead of a lambda

These are queued for stable, thanks.

Patch

diff --git a/mercurial/revset.py b/mercurial/revset.py
--- a/mercurial/revset.py
+++ b/mercurial/revset.py
@@ -2417,11 +2417,11 @@  class orderedlazyset(_orderedsetmixin, l
     def descending(self):
         if self._ascending:
             self.reverse()
 
     def __and__(self, x):
-        return orderedlazyset(self, lambda r: r in x,
+        return orderedlazyset(self, x.__contains__,
                 ascending=self._ascending)
 
     def __sub__(self, x):
         return orderedlazyset(self, lambda r: r not in x,
                 ascending=self._ascending)