# HG changeset patch # User Pierre-Yves David # Date 1410936454 25200 # Node ID a21d0484835977b0c25d2db9bf90c7be902197fe # Parent 2e40cda4b2c56567849beab12f33bd88e2157ce5 revset: simplify orderedlazyset creation in spanset method We can simply use the `self.isascending` value instead of more complex if/else clause. This get the code simpler. Benchmarks show no performances harmed in the process. diff -r 2e40cda4b2c5 -r a21d04848359 mercurial/revset.py --- a/mercurial/revset.py Tue Sep 16 23:37:03 2014 -0700 +++ b/mercurial/revset.py Tue Sep 16 23:47:34 2014 -0700 @@ -2782,18 +2782,14 @@ def __and__(self, x): if isinstance(x, baseset): x = x.set() - if self._start <= self._end: - return orderedlazyset(self, x.__contains__) - else: - return orderedlazyset(self, x.__contains__, ascending=False) + return orderedlazyset(self, x.__contains__, + ascending=self.isascending()) def __sub__(self, x): if isinstance(x, baseset): x = x.set() - if self._start <= self._end: - return orderedlazyset(self, lambda r: r not in x) - else: - return orderedlazyset(self, lambda r: r not in x, ascending=False) + return orderedlazyset(self, lambda r: r not in x, + ascending=self.isascending()) def __add__(self, x): kwargs = {} @@ -2841,10 +2837,7 @@ return self._start >= self._end def filter(self, l): - if self._start <= self._end: - return orderedlazyset(self, l) - else: - return orderedlazyset(self, l, ascending=False) + return orderedlazyset(self, l, ascending=self.isascending()) # tell hggettext to extract docstrings from these functions: i18nfunctions = symbols.values()