Mercurial > hg
comparison mercurial/smartset.py @ 32821:9b7d615108d7
smartset: micro optimize spanset.slice() to narrow range accordingly
-1ms isn't significant, but seems not bad.
revset #0: limit(0:9999, 100, 9000)
6) 0.001145
7) 0.000214
revset #3: last(0:9999, 100)
6) 0.000197
7) 0.000171
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Fri, 10 Apr 2015 00:14:16 +0900 |
parents | 653d60455dbe |
children | 27ba0d8dc26c |
comparison
equal
deleted
inserted
replaced
32820:653d60455dbe | 32821:9b7d615108d7 |
---|---|
1054 it = self.fastasc | 1054 it = self.fastasc |
1055 for x in it(): | 1055 for x in it(): |
1056 return x | 1056 return x |
1057 return None | 1057 return None |
1058 | 1058 |
1059 def _slice(self, start, stop): | |
1060 if self._hiddenrevs: | |
1061 # unoptimized since all hidden revisions in range has to be scanned | |
1062 return super(_spanset, self)._slice(start, stop) | |
1063 if self._ascending: | |
1064 x = min(self._start + start, self._end) | |
1065 y = min(self._start + stop, self._end) | |
1066 else: | |
1067 x = max(self._end - stop, self._start) | |
1068 y = max(self._end - start, self._start) | |
1069 return _spanset(x, y, self._ascending, self._hiddenrevs) | |
1070 | |
1059 def __repr__(self): | 1071 def __repr__(self): |
1060 d = {False: '-', True: '+'}[self._ascending] | 1072 d = {False: '-', True: '+'}[self._ascending] |
1061 return '<%s%s %d:%d>' % (type(self).__name__.lstrip('_'), d, | 1073 return '<%s%s %d:%d>' % (type(self).__name__.lstrip('_'), d, |
1062 self._start, self._end) | 1074 self._start, self._end) |
1063 | 1075 |