Remove the Wrapper class in between the Walker and Node.
authorstevenknight <stevenknight@fdb21ef1-2011-0410-befe-b5e4ea1792b1>
Thu, 17 Jan 2002 16:50:33 +0000 (16:50 +0000)
committerstevenknight <stevenknight@fdb21ef1-2011-0410-befe-b5e4ea1792b1>
Thu, 17 Jan 2002 16:50:33 +0000 (16:50 +0000)
git-svn-id: http://scons.tigris.org/svn/scons/trunk@211 fdb21ef1-2011-0410-befe-b5e4ea1792b1

src/CHANGES.txt
src/engine/SCons/Node/__init__.py

index 393db1ebf5c017c843e987b75d62401730d318d8..bfc275ff18f7209a7d71340d95caa5960abb408c 100644 (file)
@@ -31,6 +31,8 @@ RELEASE 0.04 -
   - Add 'Action' and 'Scanner' to the global keywords so SConscript
     files can use them too.
 
+  - Removed the Wrapper class between Nodes and Walkers.
+
 
 
 RELEASE 0.03 - Fri, 11 Jan 2002 01:09:30 -0600
index 102b532422e9a05c9c46d2eaec538900e4435d7b..b11027f8b44ea719daa0617ca233ff7d988772c8 100644 (file)
@@ -59,6 +59,7 @@ class Node:
         self.depends = []       # explicit dependencies (from Depends)
         self.implicit = {}     # implicit (scanned) dependencies
         self.parents = []
+        self.wkids = None       # Kids yet to walk, when it's an array
        self.builder = None
         self.scanners = []
         self.scanned = {}
@@ -217,16 +218,6 @@ class Node:
 def get_children(node): return node.children()
 def ignore_cycle(node, stack): pass
 
-class Wrapper:
-    def __init__(self, node, kids_func):
-        self.node = node
-        self.kids = copy.copy(kids_func(node))
-
-        # XXX randomize kids here, if requested
-
-    def __str__(self):
-        return str(self.node)
-
 class Walker:
     """An iterator for walking a Node tree.
 
@@ -244,7 +235,8 @@ class Walker:
     def __init__(self, node, kids_func=get_children, cycle_func=ignore_cycle):
         self.kids_func = kids_func
         self.cycle_func = cycle_func
-        self.stack = [Wrapper(node, self.kids_func)]
+        node.wkids = copy.copy(kids_func(node))
+        self.stack = [node]
         self.history = {} # used to efficiently detect and avoid cycles
         self.history[node] = None
 
@@ -256,15 +248,18 @@ class Walker:
        """
 
        while self.stack:
-           if self.stack[-1].kids:
-                node = self.stack[-1].kids.pop(0)
+            if self.stack[-1].wkids:
+                node = self.stack[-1].wkids.pop(0)
+                if not self.stack[-1].wkids:
+                    self.stack[-1].wkids = None
                 if self.history.has_key(node):
                     self.cycle_func(node, self.stack)
                 else:
-                    self.stack.append(Wrapper(node, self.kids_func))
+                    node.wkids = copy.copy(self.kids_func(node))
+                    self.stack.append(node)
                     self.history[node] = None
             else:
-                node = self.stack.pop().node
+                node = self.stack.pop()
                 del self.history[node]
                 return node