branchcache: store the maximum tip in a variable inside for loop
authorPulkit Goyal <pulkit@yandex-team.ru>
Sat, 27 Apr 2019 02:13:43 +0300
changeset 42214 9893d7aa7420
parent 42213 618b9ffefa87
child 42216 d0e773ad9077
branchcache: store the maximum tip in a variable inside for loop Instead of assigning self.tiprev multiple times in the for loop, and calling cl.node() on it, let's store that in a temporary variable and assign it in the end of loop. Differential Revision: https://phab.mercurial-scm.org/D6311
mercurial/branchmap.py
--- a/mercurial/branchmap.py	Sat Apr 27 23:30:19 2019 -0700
+++ b/mercurial/branchmap.py	Sat Apr 27 02:13:43 2019 +0300
@@ -378,6 +378,10 @@
         # fetch current topological heads to speed up filtering
         topoheads = set(cl.headrevs())
 
+        # new tip revision which we found after iterating items from new
+        # branches
+        ntiprev = self.tiprev
+
         # if older branchheads are reachable from new ones, they aren't
         # really branchheads. Note checking parents is insufficient:
         # 1 (branch a) -> 2 (branch b) -> 3 (branch a)
@@ -401,9 +405,12 @@
             bheadrevs = sorted(bheadset)
             self[branch] = [cl.node(rev) for rev in bheadrevs]
             tiprev = bheadrevs[-1]
-            if tiprev > self.tiprev:
-                self.tipnode = cl.node(tiprev)
-                self.tiprev = tiprev
+            if tiprev > ntiprev:
+                ntiprev = tiprev
+
+        if ntiprev > self.tiprev:
+            self.tiprev = ntiprev
+            self.tipnode = cl.node(ntiprev)
 
         if not self.validfor(repo):
             # cache key are not valid anymore