graphlog: use a set for inclusion test
authorPatrick Mezard <pmezard@gmail.com>
Sat, 30 Apr 2011 19:42:00 +0200
changeset 14088 e83ced8b6464
parent 14087 f3d585c9b042
child 14089 d3f7e110c3c0
graphlog: use a set for inclusion test This makes a big difference in performance in the special case where all revisions are being graphed.
mercurial/graphmod.py
--- a/mercurial/graphmod.py	Sat Apr 30 15:10:58 2011 +0300
+++ b/mercurial/graphmod.py	Sat Apr 30 19:42:00 2011 +0200
@@ -36,9 +36,11 @@
     lowestrev = min(revs)
     gpcache = {}
 
+    knownrevs = set(revs)
     for rev in revs:
         ctx = repo[rev]
-        parents = sorted(set([p.rev() for p in ctx.parents() if p.rev() in revs]))
+        parents = sorted(set([p.rev() for p in ctx.parents()
+                              if p.rev() in knownrevs]))
         mpars = [p.rev() for p in ctx.parents() if
                  p.rev() != nullrev and p.rev() not in parents]