From e24570215faec53f25096f7bc82ad168239caa49 Mon Sep 17 00:00:00 2001 From: Vladimir Prus Date: Fri, 17 Dec 2004 13:44:08 +0000 Subject: [PATCH] Optimization: * build/toolset.jam Setting variables on targets includes two parts: deciding what flags are applicable and applying the flags. The first part requires checking property sets and is pretty slow. It's optimised by cacheing. [SVN r26543] --- v2/build/toolset.jam | 73 ++++++++++++++++++++++++++++++++++---------- 1 file changed, 57 insertions(+), 16 deletions(-) diff --git a/v2/build/toolset.jam b/v2/build/toolset.jam index 27cad9cc5..3cac43ff4 100644 --- a/v2/build/toolset.jam +++ b/v2/build/toolset.jam @@ -199,30 +199,27 @@ rule handle-flag-value ( value * : properties * ) return $(result) ; } - -rule set-target-variables ( rule-or-module targets + : property-set ) -{ +# Given a rule name and a property set, returns a list of interleaved +# variables names and values which must be set on targets for that +# rule/property-set combination. +rule set-target-variables-aux ( rule-or-module : property-set ) +{ + local result ; properties = [ $(property-set).raw ] ; for local f in $(.$(rule-or-module).flags) { local variable = $(.$(rule-or-module).variable.$(f)) ; local condition = $(.$(rule-or-module).condition.$(f)) ; local values = $(.$(rule-or-module).values.$(f)) ; - local result ; + if ! $(condition) || [ find-property-subset $(condition) : $(properties) ] { - result += [ handle-flag-value $(values) : $(properties) ] ; - } - - # Without this test, the assignment below would create a - # target variable even if $(result) is empty. That is - # undesirable because the empty target variable would mask - # module globals intended to be used as defaults. - if $(result)-is-nonempty - { - $(variable) on $(targets) += $(result) ; + for local v in $(values) + { + result += $(variable) $(v) ; + } } } @@ -230,8 +227,52 @@ rule set-target-variables ( rule-or-module targets + : property-set ) local next = [ MATCH ^(.+)\\.([^\\.])* : $(rule-or-module) ] ; if $(next) { - set-target-variables $(next) $(targets) : $(property-set) ; - } + result += [ + set-target-variables-aux $(next[1]) : $(property-set) ] ; + } + return $(result) ; +} + + +rule set-target-variables ( rule-or-module targets + : property-set ) +{ + properties = [ $(property-set).raw ] ; + local key = $(rule-or-module).$(property-set) ; + local settings = $(.stv.$(key)) ; + if ! $(settings) + { + settings = [ + set-target-variables-aux $(rule-or-module) : $(property-set) ] ; + + if ! $(settings) + { + settings = none ; + } + .stv.$(key) = $(settings) ; + } + + if $(settings) != none + { + while $(settings) + { + # Here, $(settings[1]) is the name of variable to assign + # and $(settings[2]) is the value. + + # The value might be so needs special + # treatment. + local value = [ + handle-flag-value $(settings[2]) : $(properties) ] ; + # Without this test, the assignment below would create a + # target variable even if $(result) is empty. That is + # undesirable because the empty target variable would mask + # module globals intended to be used as defaults. + if $(value)-is-nonempty + { + $(settings[1]) on $(targets) += $(value) ; + } + settings = $(settings[3-]) ; + } + } } .toolsets += $(toolset) ;