changeset 8465:23429ebd3f9d

ancestor: use set instead of dict
author Benoit Boissinot <benoit.boissinot@ens-lyon.org>
date Sun, 17 May 2009 03:53:13 +0200
parents 7af92e70bb25
children afb3e504b558
files mercurial/ancestor.py
diffstat 1 files changed, 5 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/ancestor.py	Sun May 17 03:49:59 2009 +0200
+++ b/mercurial/ancestor.py	Sun May 17 03:53:13 2009 +0200
@@ -42,24 +42,24 @@
     # traverse ancestors in order of decreasing distance from root
     def ancestors(vertex):
         h = [(depth[vertex], vertex)]
-        seen = {}
+        seen = set()
         while h:
             d, n = heapq.heappop(h)
             if n not in seen:
-                seen[n] = 1
+                seen.add(n)
                 yield (d, n)
                 for p in parentcache[n]:
                     heapq.heappush(h, (depth[p], p))
 
     def generations(vertex):
-        sg, s = None, {}
+        sg, s = None, set()
         for g, v in ancestors(vertex):
             if g != sg:
                 if sg:
                     yield sg, s
-                sg, s = g, {v:1}
+                sg, s = g, set((v,))
             else:
-                s[v] = 1
+                s.add(v)
         yield sg, s
 
     x = generations(a)