# HG changeset patch # User Pierre-Yves David # Date 2014-04-26 07:38:02 # Node ID b9defeeb62e61f089a88e87b8a6705f3367ae256 # Parent c77418938d051c1aa9376de6dde338cb1f3ba400 spanset: directly use __contains__ instead of a lambda Spanset are massively used in revset. First because the initial subset itself is a repo wide spanset. We speed up the __and__ operation by getting rid of a gratuitous lambda call. A more long terms solution would be to: 1. speed up operation between spansets, 2. have a special smartset for `all` revisions. In the mean time, this is a very simple fix that buyback some of the performance regression. Below is performance benchmark for trival `and` operation between two spansets. (Run on an unspecified fairly large repository.) revset tip:0 2.9.2) wall 0.282543 comb 0.280000 user 0.260000 sys 0.020000 (best of 35) before) wall 0.819181 comb 0.820000 user 0.820000 sys 0.000000 (best of 12) after) wall 0.645358 comb 0.650000 user 0.650000 sys 0.000000 (best of 16) Proof of concept implementation of an `all` smartset brings this to 0.10 but it's too invasive for stable. diff --git a/mercurial/revset.py b/mercurial/revset.py --- a/mercurial/revset.py +++ b/mercurial/revset.py @@ -2797,9 +2797,9 @@ class spanset(_orderedsetmixin): if isinstance(x, baseset): x = x.set() if self._start <= self._end: - return orderedlazyset(self, lambda r: r in x) + return orderedlazyset(self, x.__contains__) else: - return orderedlazyset(self, lambda r: r in x, ascending=False) + return orderedlazyset(self, x.__contains__, ascending=False) def __sub__(self, x): if isinstance(x, baseset):