stablerange: adds some caching of the subranges
The goal of subranges is to be as reusable as possible, so we cache the subrange
relationship to take advantage of this.
--- a/hgext3rd/evolve/obsdiscovery.py Sat Mar 11 12:15:56 2017 -0800
+++ b/hgext3rd/evolve/obsdiscovery.py Sat Mar 11 12:21:22 2017 -0800
@@ -579,6 +579,11 @@
return result
def subranges(self):
+ if not util.safehasattr(self._repo, '_subrangecache'):
+ self._repo._subrangecache = {}
+ cached = self._repo._subrangecache.get(self)
+ if cached is not None:
+ return cached
if len(self) == 1:
return []
step = _hlp2(self.depth)
@@ -589,10 +594,13 @@
step //= 2
if self.index == standard_start:
slicesize = _hlp2(len(self))
- return self._slicesat(self.index + slicesize)
+ slicepoint = self.index + slicesize
else:
assert standard_start < self.depth
- return self._slicesat(standard_start)
+ slicepoint = standard_start
+ result = self._slicesat(slicepoint)
+ self._repo._subrangecache[self] = result
+ return result
@util.propertycache
def obshash(self):