revset: simplify orderedlazyset creation in spanset method
authorPierre-Yves David <pierre-yves.david@fb.com>
Tue, 16 Sep 2014 23:47:34 -0700
changeset 22483 a21d04848359
parent 22482 2e40cda4b2c5
child 22484 2b5940f64750
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.
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()