revset: prefetch method in "parents"
authorPierre-Yves David <pierre-yves.david@fb.com>
Thu, 02 Jul 2015 23:46:18 -0700
changeset 25716 d50677c3bf44
parent 25713 2ca116614cfc
child 25717 46e2c57026bc
revset: prefetch method in "parents" As already demonstrated, saving attribute lookup gains us some minor but noticeable performance improvements. revset #0: parents(all()) before) 0.024169 after ) 0.022756 94%
mercurial/revset.py
--- a/mercurial/revset.py	Wed Jul 01 13:14:03 2015 -0700
+++ b/mercurial/revset.py	Thu Jul 02 23:46:18 2015 -0700
@@ -1478,11 +1478,13 @@
     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