[PATCH 3 of 3] revset: simplify orderedlazyset creation in spanset method
Pierre-Yves David
pierre-yves.david at ens-lyon.org
Thu Sep 18 13:26:26 CDT 2014
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david at fb.com>
# Date 1410936454 25200
# Tue Sep 16 23:47:34 2014 -0700
# Node ID d26e9a84e752ca0eaa2533d9a3fd3ab614e17b38
# Parent 862bc6d9cdea929b80bf3635f8b66d7b39ebd6ad
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 --git a/mercurial/revset.py b/mercurial/revset.py
--- a/mercurial/revset.py
+++ b/mercurial/revset.py
@@ -2780,22 +2780,18 @@ class spanset(_orderedsetmixin):
return False
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 = {}
if self.isascending() and x.isascending():
kwargs['ascending'] = True
@@ -2839,12 +2835,9 @@ class spanset(_orderedsetmixin):
def isdescending(self):
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()
More information about the Mercurial-devel
mailing list