branchpoint: remove useless intermediate set creation
authorPierre-Yves David <pierre-yves.david@logilab.fr>
Mon, 15 Oct 2012 17:43:05 +0200
changeset 17786 72c234081ae1
parent 17785 ac5c9c8046f7
child 17787 21503aa02d4f
branchpoint: remove useless intermediate set creation We don't need to compute the set of all branchpoints. We can just check the number of children that element of subset have. The extra work did not seems to had particular performance impact but the code is simpler this way.
mercurial/revset.py
--- a/mercurial/revset.py	Mon Oct 15 17:42:40 2012 +0200
+++ b/mercurial/revset.py	Mon Oct 15 17:43:05 2012 +0200
@@ -933,9 +933,7 @@
         for p in cl.parentrevs(r):
             if p >= baserev:
                 parentscount[p - baserev] += 1
-    branchpoints = set((baserev + i) for i in xrange(len(parentscount))
-                       if parentscount[i] > 1)
-    return [r for r in subset if r in branchpoints]
+    return [r for r in subset if (parentscount[r - baserev] > 1)]
 
 def minrev(repo, subset, x):
     """``min(set)``