changeset 22483:a21d04848359

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.
author Pierre-Yves David <pierre-yves.david@fb.com>
date Tue, 16 Sep 2014 23:47:34 -0700
parents 2e40cda4b2c5
children 2b5940f64750
files mercurial/revset.py
diffstat 1 files changed, 5 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- 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()