From bf70cd5b8154baba75a32acded4987fa5fb530a7 Mon Sep 17 00:00:00 2001 From: stevenknight Date: Sat, 5 Mar 2005 15:50:59 +0000 Subject: [PATCH] Reduce gen_binfo() time for very long source lists. git-svn-id: http://scons.tigris.org/svn/scons/trunk@1245 fdb21ef1-2011-0410-befe-b5e4ea1792b1 --- src/engine/SCons/Executor.py | 15 +++++++++++---- src/engine/SCons/ExecutorTests.py | 23 ++++++++++++++++++----- src/engine/SCons/Node/__init__.py | 6 ++---- 3 files changed, 31 insertions(+), 13 deletions(-) diff --git a/src/engine/SCons/Executor.py b/src/engine/SCons/Executor.py index c425a052..fb156617 100644 --- a/src/engine/SCons/Executor.py +++ b/src/engine/SCons/Executor.py @@ -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 ([], [], []) diff --git a/src/engine/SCons/ExecutorTests.py b/src/engine/SCons/ExecutorTests.py index d3af914f..d16b137a 100644 --- a/src/engine/SCons/ExecutorTests.py +++ b/src/engine/SCons/ExecutorTests.py @@ -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 diff --git a/src/engine/SCons/Node/__init__.py b/src/engine/SCons/Node/__init__.py index 825e1324..9c15659d 100644 --- a/src/engine/SCons/Node/__init__.py +++ b/src/engine/SCons/Node/__init__.py @@ -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) -- 2.26.2