From 18ba1ff5285ec24eef4301875032035cbef93a36 Mon Sep 17 00:00:00 2001 From: stevenknight Date: Fri, 1 Mar 2002 14:20:18 +0000 Subject: [PATCH] Performance: Use a dictionary, not a list, for a Node's parents. (Stephen Kennedy) git-svn-id: http://scons.tigris.org/svn/scons/trunk@280 fdb21ef1-2011-0410-befe-b5e4ea1792b1 --- src/CHANGES.txt | 4 ++++ src/engine/SCons/Node/NodeTests.py | 9 --------- src/engine/SCons/Node/__init__.py | 11 +++-------- 3 files changed, 7 insertions(+), 17 deletions(-) diff --git a/src/CHANGES.txt b/src/CHANGES.txt index ddbbdfcb..cc3db983 100644 --- a/src/CHANGES.txt +++ b/src/CHANGES.txt @@ -10,6 +10,10 @@ RELEASE 0.06 - + From Stephen Kennedy: + + - Performance: Use a dictionary, not a list, for a Node's parents. + From Steven Knight: - Add .zip files to the packages we build. diff --git a/src/engine/SCons/Node/NodeTests.py b/src/engine/SCons/Node/NodeTests.py index 54f06e68..574e9cd1 100644 --- a/src/engine/SCons/Node/NodeTests.py +++ b/src/engine/SCons/Node/NodeTests.py @@ -468,15 +468,6 @@ class NodeTestCase(unittest.TestCase): assert five in kids assert six in kids - def test_add_parent(self): - """Test adding parents to a Node.""" - node = SCons.Node.Node() - parent = SCons.Node.Node() - node._add_parent(parent) - assert node.get_parents() == [parent] - node._add_parent(parent) - assert node.get_parents() == [parent] - def test_state(self): """Test setting and getting the state of a node """ diff --git a/src/engine/SCons/Node/__init__.py b/src/engine/SCons/Node/__init__.py index 918543dd..4c54c533 100644 --- a/src/engine/SCons/Node/__init__.py +++ b/src/engine/SCons/Node/__init__.py @@ -60,7 +60,7 @@ class Node: self.depends = [] # explicit dependencies (from Depends) self.implicit = {} # implicit (scanned) dependencies self.ignore = [] # dependencies to ignore - self.parents = [] + self.parents = {} self.wkids = None # Kids yet to walk, when it's an array self.builder = None self.scanners = [] @@ -215,12 +215,7 @@ class Node: collection.extend(child) for c in child: - c._add_parent(self) - - def _add_parent(self, parent): - """Adds 'parent' to the list of parents of this node""" - - if parent not in self.parents: self.parents.append(parent) + c.parents[self] = 1 def add_wkid(self, wkid): """Add a node to the list of kids waiting to be evaluated""" @@ -240,7 +235,7 @@ class Node: + reduce(lambda x, y: x + y, self.implicit.values(), []) def get_parents(self): - return self.parents + return self.parents.keys() def set_state(self, state): self.state = state -- 2.26.2