changeset 25716:d50677c3bf44

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%
author Pierre-Yves David <pierre-yves.david@fb.com>
date Thu, 02 Jul 2015 23:46:18 -0700
parents 2ca116614cfc
children 46e2c57026bc
files mercurial/revset.py
diffstat 1 files changed, 4 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- 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