Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r83834 - in trunk/tools/build/v2: engine kernel
From: steven_at_[hidden]
Date: 2013-04-10 14:50:34


Author: steven_watanabe
Date: 2013-04-10 14:50:33 EDT (Wed, 10 Apr 2013)
New Revision: 83834
URL: http://svn.boost.org/trac/boost/changeset/83834

Log:
Avoid creating the hash in an object when it isn't needed.
Text files modified:
   trunk/tools/build/v2/engine/class.c | 11 +++++++++++
   trunk/tools/build/v2/engine/constants.c | 3 +++
   trunk/tools/build/v2/engine/constants.h | 1 +
   trunk/tools/build/v2/kernel/class.jam | 3 +--
   4 files changed, 16 insertions(+), 2 deletions(-)

Modified: trunk/tools/build/v2/engine/class.c
==============================================================================
--- trunk/tools/build/v2/engine/class.c (original)
+++ trunk/tools/build/v2/engine/class.c 2013-04-10 14:50:33 EDT (Wed, 10 Apr 2013)
@@ -149,6 +149,17 @@
 
     class_module = bindmodule( name );
 
+ {
+ /*
+ Initialize variables that Boost.Build inserts in every object.
+ We want to avoid creating the object's hash if it isn't needed.
+ */
+ int num = class_module->num_fixed_variables;
+ module_add_fixed_var( class_module, constant_name, &num );
+ module_add_fixed_var( class_module, constant_class, &num );
+ module_set_fixed_variables( class_module, num );
+ }
+
     var_set( class_module, constant_name, xname, VAR_SET );
     var_set( class_module, constant_bases, bases, VAR_SET );
 

Modified: trunk/tools/build/v2/engine/constants.c
==============================================================================
--- trunk/tools/build/v2/engine/constants.c (original)
+++ trunk/tools/build/v2/engine/constants.c 2013-04-10 14:50:33 EDT (Wed, 10 Apr 2013)
@@ -28,6 +28,7 @@
     constant_true = object_new( "true" );
     constant_name = object_new( "__name__" );
     constant_bases = object_new( "__bases__" );
+ constant_class = object_new( "__class__" );
     constant_typecheck = object_new( ".typecheck" );
     constant_builtin = object_new( "(builtin)" );
     constant_HCACHEFILE = object_new( "HCACHEFILE" );
@@ -84,6 +85,7 @@
     object_free( constant_true );
     object_free( constant_name );
     object_free( constant_bases );
+ object_free( constant_class );
     object_free( constant_typecheck );
     object_free( constant_builtin );
     object_free( constant_HCACHEFILE );
@@ -138,6 +140,7 @@
 OBJECT * constant_true;
 OBJECT * constant_name;
 OBJECT * constant_bases;
+OBJECT * constant_class;
 OBJECT * constant_typecheck;
 OBJECT * constant_builtin;
 OBJECT * constant_HCACHEFILE;

Modified: trunk/tools/build/v2/engine/constants.h
==============================================================================
--- trunk/tools/build/v2/engine/constants.h (original)
+++ trunk/tools/build/v2/engine/constants.h 2013-04-10 14:50:33 EDT (Wed, 10 Apr 2013)
@@ -25,6 +25,7 @@
 extern OBJECT * constant_true; /* "true" */
 extern OBJECT * constant_name; /* "__name__" */
 extern OBJECT * constant_bases; /* "__bases__" */
+extern OBJECT * constant_class; /* "__class__" */
 extern OBJECT * constant_typecheck; /* ".typecheck" */
 extern OBJECT * constant_builtin; /* "(builtin)" */
 extern OBJECT * constant_HCACHEFILE; /* "HCACHEFILE" */

Modified: trunk/tools/build/v2/kernel/class.jam
==============================================================================
--- trunk/tools/build/v2/kernel/class.jam (original)
+++ trunk/tools/build/v2/kernel/class.jam 2013-04-10 14:50:33 EDT (Wed, 10 Apr 2013)
@@ -82,9 +82,8 @@
     .next-instance ?= 1 ;
     local id = object($(class))@$(.next-instance) ;
 
- xinit $(id) : $(class) ;
-
     INSTANCE $(id) : class@$(class) ;
+ xinit $(id) : $(class) ;
     IMPORT_MODULE $(id) ;
     $(id).__init__ $(args) : $(2) : $(3) : $(4) : $(5) : $(6) : $(7) : $(8) :
         $(9) : $(10) : $(11) : $(12) : $(13) : $(14) : $(15) : $(16) : $(17) :


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk