stablerange: directly perform slicing in the getting method
authorPierre-Yves David <pierre-yves.david@ens-lyon.org>
Sun, 19 Mar 2017 04:45:28 +0100
changeset 2133 323480863248
parent 2132 d77262807411
child 2134 b86b94434de7
stablerange: directly perform slicing in the getting method Now that all necessary functions are available, we simply apply the standard slicing on cache miss and proceed.
hgext3rd/evolve/stablerange.py
--- a/hgext3rd/evolve/stablerange.py	Sun Mar 19 04:43:33 2017 +0100
+++ b/hgext3rd/evolve/stablerange.py	Sun Mar 19 04:45:28 2017 +0100
@@ -227,9 +227,11 @@
             return cached
         if self.rangelength(repo, rangeid) == 1:
             value = []
-            self._subrangescache[rangeid] = value
-            return value
-        return None
+        else:
+            slicepoint = self._slicepoint(repo, rangeid)
+            value = self._slicesrangeat(repo, rangeid, slicepoint)
+        self._subrangescache[rangeid] = value
+        return value
 
     def setsubranges(self, rangeid, value):
         # XXX temporary cache setter as value computation are performed outside
@@ -341,14 +343,7 @@
         return r
 
     def subranges(self):
-        cache = self._repo.stablerange
-        cached = cache.subranges(self._repo, self)
-        if cached is not None:
-            return cached
-        slicepoint = cache._slicepoint(self._repo, self)
-        result = cache._slicesrangeat(self._repo, self, slicepoint)
-        self._repo.stablerange.setsubranges(self, result)
-        return result
+        return self._repo.stablerange.subranges(self._repo, self)
 
     @util.propertycache
     def obshash(self):