Patchwork [1,of,2] obsutil: prefetch method in allpredecessors loop

login
register
mail settings
Submitter Boris Feld
Date Nov. 2, 2018, 8:58 a.m.
Message ID <a2497966bf47a02572bb.1541149083@localhost.localdomain>
Download mbox | patch
Permalink /patch/36321/
State Accepted
Headers show

Comments

Boris Feld - Nov. 2, 2018, 8:58 a.m.
# HG changeset patch
# User Boris Feld <boris.feld@octobus.net>
# Date 1539903198 -7200
#      Fri Oct 19 00:53:18 2018 +0200
# Node ID a2497966bf47a02572bbad448458d5a4b94fe77e
# Parent  2c0aa02ecd5a05ae76b6345962ee3a0ef773bd8a
# EXP-Topic bettertroubles
# Available At https://bitbucket.org/octobus/mercurial-devel/
#              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r a2497966bf47
obsutil: prefetch method in allpredecessors loop

We don't expect a massive speedup from this, but the change was laying around
in my repository and it cannot hurt.

Patch

diff --git a/mercurial/obsutil.py b/mercurial/obsutil.py
--- a/mercurial/obsutil.py
+++ b/mercurial/obsutil.py
@@ -148,10 +148,11 @@  def allpredecessors(obsstore, nodes, ign
 
     remaining = set(nodes)
     seen = set(remaining)
+    prec = obsstore.predecessors.get
     while remaining:
         current = remaining.pop()
         yield current
-        for mark in obsstore.predecessors.get(current, ()):
+        for mark in prec(current, ()):
             # ignore marker flagged with specified flag
             if mark[2] & ignoreflags:
                 continue