Patchwork revert: prefetch method in "parents"

login
register
mail settings
Submitter Pierre-Yves David
Date July 3, 2015, 4:52 p.m.
Message ID <0bf809bc323ce07f94f7.1435942368@marginatus.alto.octopoid.net>
Download mbox | patch
Permalink /patch/9885/
State Accepted
Headers show

Comments

Pierre-Yves David - July 3, 2015, 4:52 p.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@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%
Matt Mackall - July 7, 2015, 7:39 p.m.
On Fri, 2015-07-03 at 09:52 -0700, Pierre-Yves David wrote:
> # HG changeset patch
> # User Pierre-Yves David <pierre-yves.david@fb.com>
> # Date 1435905978 25200
> #      Thu Jul 02 23:46:18 2015 -0700
> # Node ID 0bf809bc323ce07f94f731f62f83a98ba96eed91
> # Parent  84518051bc3b851f736872df045d662de548b3c9
> revert: prefetch method in "parents"
  ^^^^^^

Queued, with highly-confusing spelling error corrected.

Patch

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>"""