Performance: Use a dictionary, not a list, for a Node's parents. (Stephen Kennedy)
authorstevenknight <stevenknight@fdb21ef1-2011-0410-befe-b5e4ea1792b1>
Fri, 1 Mar 2002 14:20:18 +0000 (14:20 +0000)
committerstevenknight <stevenknight@fdb21ef1-2011-0410-befe-b5e4ea1792b1>
Fri, 1 Mar 2002 14:20:18 +0000 (14:20 +0000)
git-svn-id: http://scons.tigris.org/svn/scons/trunk@280 fdb21ef1-2011-0410-befe-b5e4ea1792b1

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

index ddbbdfcbea4103e3e54237e8c4a39a2218594955..cc3db98312a667c4ddf501683c93e63101ff3dc0 100644 (file)
 
 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.
index 54f06e6857b4fbdf1264ab40ce6ae633919a10a9..574e9cd14b47e7df7eb7a0c9ba9525e9bef631df 100644 (file)
@@ -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
        """
index 918543dd6aee1c1cebcd21ba43a6b6a75c8fe0a1..4c54c53363865015b97e53cf6404a4bc9998c9b3 100644 (file)
@@ -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