Mercurial > hg
comparison mercurial/revset.py @ 22687:d9cc1be5acec
revset: use direct access to __contains__ in spanset.__sub__
Using `x.__contains__(r)` instead of `r in x` does not matter for built-in type
(set) but have a positive impact for all other classes. This will let us drop
some usage of baseset.set() in future patches. This also probably improves some
performance.
author | Pierre-Yves David <pierre-yves.david@fb.com> |
---|---|
date | Wed, 01 Oct 2014 15:53:42 -0500 |
parents | 2717dcff7be1 |
children | cac9b3591753 |
comparison
equal
deleted
inserted
replaced
22686:2717dcff7be1 | 22687:d9cc1be5acec |
---|---|
2821 ascending=self.isascending()) | 2821 ascending=self.isascending()) |
2822 | 2822 |
2823 def __sub__(self, x): | 2823 def __sub__(self, x): |
2824 if isinstance(x, baseset): | 2824 if isinstance(x, baseset): |
2825 x = x.set() | 2825 x = x.set() |
2826 return orderedlazyset(self, lambda r: r not in x, | 2826 filterfunc = x.__contains__ |
2827 return orderedlazyset(self, lambda r: not filterfunc(r), | |
2827 ascending=self.isascending()) | 2828 ascending=self.isascending()) |
2828 | 2829 |
2829 def __add__(self, x): | 2830 def __add__(self, x): |
2830 kwargs = {} | 2831 kwargs = {} |
2831 if self.isascending() and x.isascending(): | 2832 if self.isascending() and x.isascending(): |