mirror of
https://github.com/facebook/sapling.git
synced 2024-10-08 15:57:43 +03:00
revset: do less lookup during spanset.__contains__
Attribute lookup is slow in python. So this version is going to be a bit faster. This does not have a visible impact since the rest of the stack is much slower but this shaves the yak a few extra nanometers. Moreover the new version is more readable so it worth doing this change for code quality purpose. This optimisation was approved by a core python dev.
This commit is contained in:
parent
f89da734dc
commit
e291b5bdba
@ -2793,9 +2793,11 @@ class _spanset(_orderedsetmixin):
|
||||
yield r
|
||||
|
||||
def __contains__(self, rev):
|
||||
return (((self._end < rev <= self._start)
|
||||
or (self._start <= rev < self._end))
|
||||
and not (self._hiddenrevs and rev in self._hiddenrevs))
|
||||
start = self._start
|
||||
end = self._end
|
||||
hidden = self._hiddenrevs
|
||||
return (((end < rev <= start) or (start <= rev and rev < end))
|
||||
and not (hidden and rev in hidden))
|
||||
|
||||
def __nonzero__(self):
|
||||
for r in self:
|
||||
|
Loading…
Reference in New Issue
Block a user