Mercurial > hg-stable
changeset 22526:1e6d2b6b37ea
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.
author | Pierre-Yves David <pierre-yves.david@fb.com> |
---|---|
date | Fri, 25 Apr 2014 17:53:58 -0700 |
parents | 764127f58903 |
children | 6e38b5d49977 |
files | mercurial/revset.py |
diffstat | 1 files changed, 5 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/revset.py Tue Sep 16 23:10:39 2014 -0700 +++ b/mercurial/revset.py Fri Apr 25 17:53:58 2014 -0700 @@ -2793,9 +2793,11 @@ 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: