From 32c629f4ac95883cecdc99356792bda45933b674 Mon Sep 17 00:00:00 2001 From: Vladimir Prus Date: Tue, 20 Sep 2005 13:11:47 +0000 Subject: [PATCH] Optimize scanner construction. Instead of calling property.select on raw properties list for each file, use a cache keyed by property-set instance. [SVN r31055] --- v2/build/scanner.jam | 18 +++++++++++------- v2/build/type.jam | 2 +- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/v2/build/scanner.jam b/v2/build/scanner.jam index 10af04c07..b070f0fa5 100644 --- a/v2/build/scanner.jam +++ b/v2/build/scanner.jam @@ -27,7 +27,7 @@ # way, instead of relying on just target type. import "class" : new ; -import property virtual-target ; +import property virtual-target property-set ; # Base scanner class. class scanner @@ -87,21 +87,25 @@ class common-scanner : scanner # Returns an instance of previously registered scanner, # with the specified properties. -rule get ( scanner-class : properties * ) +rule get ( scanner-class : property-set ) { if ! $(scanner-class) in $(.registered) { error "attempt to get unregisted scanner" ; } - local r = [ property.select $(.relevant-properties.$(scanner-class)) : - $(properties) ] ; + + local r = $(.rv-cache.$(property-set)) ; if ! $(r) { - r = "" ; - } + r = [ property-set.create + [ property.select $(.relevant-properties.$(scanner-class)) : + [ $(property-set).raw ] ] ] ; + .rv-cache.$(property-set) = $(r) ; + } + if ! $(scanner.$(scanner-class).$(r:J=-)) { - scanner.$(scanner-class).$(r:J=-) = [ new $(scanner-class) $(r) ] ; + scanner.$(scanner-class).$(r:J=-) = [ new $(scanner-class) [ $(r).raw ] ] ; } return $(scanner.$(scanner-class).$(r:J=-)) ; } diff --git a/v2/build/type.jam b/v2/build/type.jam index fb99a5f6c..fe193e5cf 100644 --- a/v2/build/type.jam +++ b/v2/build/type.jam @@ -156,7 +156,7 @@ rule set-scanner ( type : scanner ) rule get-scanner ( type : property-set ) { if $(.scanner.$(type)) { - return [ scanner.get $(.scanner.$(type)) : [ $(property-set).raw ] ] ; + return [ scanner.get $(.scanner.$(type)) : $(property-set) ] ; } }