Reduce gen_binfo() time for very long source lists.
authorstevenknight <stevenknight@fdb21ef1-2011-0410-befe-b5e4ea1792b1>
Sat, 5 Mar 2005 15:50:59 +0000 (15:50 +0000)
committerstevenknight <stevenknight@fdb21ef1-2011-0410-befe-b5e4ea1792b1>
Sat, 5 Mar 2005 15:50:59 +0000 (15:50 +0000)
git-svn-id: http://scons.tigris.org/svn/scons/trunk@1245 fdb21ef1-2011-0410-befe-b5e4ea1792b1

src/engine/SCons/Executor.py
src/engine/SCons/ExecutorTests.py
src/engine/SCons/Node/__init__.py

index c425a052351b54276ff082345e47889c33c198bc..fb156617cb8b0642819ea6dd1a9895396a628f6c 100644 (file)
@@ -187,12 +187,19 @@ class Executor:
         """
         return filter(lambda s: s.missing(), self.sources)
 
-    def get_source_binfo(self, calc):
+    def get_source_binfo(self, calc, ignore=[]):
         """
+        Return three lists, one of the source files, one of their
+        calculated signatures, and one of their strings (path names).
         __cacheable__
         """
+        sourcelist = self.sources
+        if ignore:
+            sourcelist = filter(lambda s, i=ignore: not s in i, sourcelist)
         calc_signature = lambda node, calc=calc: node.calc_signature(calc)
-        return map(lambda s, c=calc_signature: (s, c(s), str(s)), self.sources)
+        return (sourcelist,
+                map(calc_signature, sourcelist),
+                map(str,  sourcelist))
 
 
 
@@ -219,8 +226,8 @@ class Null:
         pass
     def get_missing_sources(self):
         return []
-    def get_source_binfo(self, calc):
-        return []
+    def get_source_binfo(self, calc, ignore=[]):
+        return ([], [], [])
 
 
 
index d3af914f4058e8e5e43af866cb1217668170ae94..d16b137a8dd717d462b2fd3474665c1cbf8d3cff 100644 (file)
@@ -340,12 +340,25 @@ class ExecutorTestCase(unittest.TestCase):
     def test_get_source_binfo(self):
         """Test fetching the build signature info for the sources"""
         env = MyEnvironment()
-        targets = [MyNode('t')]
-        sources = [MyNode('s1'), MyNode('s2')]
-        x = SCons.Executor.Executor('b', env, [{}], targets, sources)
+        t1 = MyNode('t')
+        s1 = MyNode('s1')
+        s2 = MyNode('s2')
+        x = SCons.Executor.Executor('b', env, [{}], [t1], [s1, s2])
+
         b = x.get_source_binfo('C')
-        assert b == [(sources[0], 'cs-C-s1', 's1'),
-                     (sources[1], 'cs-C-s2', 's2')], b
+        assert b == ([s1, s2],
+                     ['cs-C-s1', 'cs-C-s2'],
+                     ['s1', 's2']), b
+
+        b = x.get_source_binfo('C', [s1])
+        assert b == ([s2],
+                     ['cs-C-s2'],
+                     ['s2']), b
+
+        b = x.get_source_binfo('C', [s2])
+        assert b == ([s1],
+                     ['cs-C-s1'],
+                     ['s1']), b
 
 
 
index 825e1324397289696af8fbeffd0c2385355d1852..9c15659dba01bd181105cdb09aee9879267b0547 100644 (file)
@@ -578,18 +578,16 @@ class Node:
 
         executor = self.get_executor()
 
-        sourcelist = executor.get_source_binfo(calc)
+        sourcelist, sourcesigs, bsources = executor.get_source_binfo(calc, self.ignore)
         depends = self.depends
         implicit = self.implicit or []
 
         if self.ignore:
-            sourcelist = filter(lambda t, s=self: s.do_not_ignore(t[0]), sourcelist)
             depends = filter(self.do_not_ignore, depends)
             implicit = filter(self.do_not_ignore, implicit)
 
         def calc_signature(node, calc=calc):
             return node.calc_signature(calc)
-        sourcesigs = map(lambda t: t[1], sourcelist)
         dependsigs = map(calc_signature, depends)
         implicitsigs = map(calc_signature, implicit)
 
@@ -600,7 +598,7 @@ class Node:
             binfo.bactsig = calc.module.signature(executor)
             sigs.append(binfo.bactsig)
 
-        binfo.bsources = map(lambda t: t[2], sourcelist)
+        binfo.bsources = bsources
         binfo.bdepends = map(str, depends)
         binfo.bimplicit = map(str, implicit)