[PATCH] revert: prefetch method in "parents"

Pierre-Yves David pierre-yves.david at ens-lyon.org
Fri Jul 3 11:52:48 CDT 2015


# HG changeset patch
# User Pierre-Yves David <pierre-yves.david at fb.com>
# Date 1435905978 25200
#      Thu Jul 02 23:46:18 2015 -0700
# Node ID 0bf809bc323ce07f94f731f62f83a98ba96eed91
# Parent  84518051bc3b851f736872df045d662de548b3c9
revert: prefetch method in "parents"

As already demonstrated, saving attribut lookup gain use some minor but
noticeable performance improvements.

revset #0: parents(all())
before) 0.024169
after ) 0.022756  94%

diff --git a/mercurial/revset.py b/mercurial/revset.py
--- a/mercurial/revset.py
+++ b/mercurial/revset.py
@@ -1476,15 +1476,17 @@ def parents(repo, subset, x):
     if x is None:
         ps = set(p.rev() for p in repo[x].parents())
     else:
         ps = set()
         cl = repo.changelog
+        up = ps.update
+        parentrevs = cl.parentrevs
         for r in getset(repo, fullreposet(repo), x):
             if r is None:
-                ps.update(p.rev() for p in repo[r].parents())
+                up(p.rev() for p in repo[r].parents())
             else:
-                ps.update(cl.parentrevs(r))
+                up(parentrevs(r))
     ps -= set([node.nullrev])
     return subset & ps
 
 def _phase(repo, subset, target):
     """helper to select all rev in phase <target>"""


More information about the Mercurial-devel mailing list