From a4cb06495e62e3f75ff97ee862b8f1fd22d654ad Mon Sep 17 00:00:00 2001 From: stevenknight Date: Thu, 17 Jan 2002 16:50:33 +0000 Subject: [PATCH] Remove the Wrapper class in between the Walker and Node. git-svn-id: http://scons.tigris.org/svn/scons/trunk@211 fdb21ef1-2011-0410-befe-b5e4ea1792b1 --- src/CHANGES.txt | 2 ++ src/engine/SCons/Node/__init__.py | 25 ++++++++++--------------- 2 files changed, 12 insertions(+), 15 deletions(-) diff --git a/src/CHANGES.txt b/src/CHANGES.txt index 393db1eb..bfc275ff 100644 --- a/src/CHANGES.txt +++ b/src/CHANGES.txt @@ -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 diff --git a/src/engine/SCons/Node/__init__.py b/src/engine/SCons/Node/__init__.py index 102b5324..b11027f8 100644 --- a/src/engine/SCons/Node/__init__.py +++ b/src/engine/SCons/Node/__init__.py @@ -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 -- 2.26.2