Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r77510 - in trunk/tools/build/v2/engine: . modules
From: steven_at_[hidden]
Date: 2012-03-23 18:30:35


Author: steven_watanabe
Date: 2012-03-23 18:30:33 EDT (Fri, 23 Mar 2012)
New Revision: 77510
URL: http://svn.boost.org/trac/boost/changeset/77510

Log:
Remove the first argument of list_copy, since it's always L0.
Text files modified:
   trunk/tools/build/v2/engine/builtins.c | 2
   trunk/tools/build/v2/engine/command.c | 4 +-
   trunk/tools/build/v2/engine/function.c | 36 ++++++++++++++--------------
   trunk/tools/build/v2/engine/hcache.c | 6 ++--
   trunk/tools/build/v2/engine/lists.c | 50 +++++++++++++++++++++++----------------
   trunk/tools/build/v2/engine/lists.h | 2
   trunk/tools/build/v2/engine/make1.c | 6 ++--
   trunk/tools/build/v2/engine/modules/property-set.c | 4 +-
   trunk/tools/build/v2/engine/rules.c | 2
   9 files changed, 60 insertions(+), 52 deletions(-)

Modified: trunk/tools/build/v2/engine/builtins.c
==============================================================================
--- trunk/tools/build/v2/engine/builtins.c (original)
+++ trunk/tools/build/v2/engine/builtins.c 2012-03-23 18:30:33 EDT (Fri, 23 Mar 2012)
@@ -1335,7 +1335,7 @@
 
 LIST * builtin_update( FRAME * frame, int flags )
 {
- LIST * result = list_copy( L0, targets_to_update() );
+ LIST * result = list_copy( targets_to_update() );
     LIST * arg1 = lol_get( frame->args, 0 );
     LISTITER iter = list_begin( arg1 ), end = list_end( arg1 );
     clear_targets_to_update();

Modified: trunk/tools/build/v2/engine/command.c
==============================================================================
--- trunk/tools/build/v2/engine/command.c (original)
+++ trunk/tools/build/v2/engine/command.c 2012-03-23 18:30:33 EDT (Fri, 23 Mar 2012)
@@ -51,8 +51,8 @@
     frame_init( frame );
     frame->module = rule->module;
     lol_init( frame->args );
- lol_add( frame->args, list_copy( L0, targets ) );
- lol_add( frame->args, list_copy( L0, sources ) );
+ lol_add( frame->args, list_copy( targets ) );
+ lol_add( frame->args, list_copy( sources ) );
     function_run_actions( rule->actions->command, frame, stack_global(), cmd->buf );
     frame_free( frame );
 

Modified: trunk/tools/build/v2/engine/function.c
==============================================================================
--- trunk/tools/build/v2/engine/function.c (original)
+++ trunk/tools/build/v2/engine/function.c 2012-03-23 18:30:33 EDT (Fri, 23 Mar 2012)
@@ -245,7 +245,7 @@
 LIST * frame_get_local( FRAME * frame, int idx )
 {
     /* The only local variables are the arguments */
- return list_copy( L0, lol_get( frame->args, idx ) );
+ return list_copy( lol_get( frame->args, idx ) );
 }
 
 static OBJECT * function_get_constant( JAM_FUNCTION * function, int idx )
@@ -255,7 +255,7 @@
 
 static LIST * function_get_variable( JAM_FUNCTION * function, FRAME * frame, int idx )
 {
- return list_copy( L0, var_get( frame->module, function->constants[idx] ) );
+ return list_copy( var_get( frame->module, function->constants[idx] ) );
 }
 
 static void function_set_variable( JAM_FUNCTION * function, FRAME * frame, int idx, LIST * value )
@@ -363,11 +363,11 @@
     int idx = get_argument_index( object_str( name ) );
     if( idx != -1 )
     {
- return list_copy( L0, lol_get( frame->args, idx ) );
+ return list_copy( lol_get( frame->args, idx ) );
     }
     else
     {
- return list_copy( L0, var_get( frame->module, name ) );
+ return list_copy( var_get( frame->module, name ) );
     }
 }
 
@@ -3180,7 +3180,7 @@
 
         case INSTR_PUSH_VAR_FIXED:
         {
- stack_push( s, list_copy( L0, frame->module->fixed_variables[ code->arg ] ) );
+ stack_push( s, list_copy( frame->module->fixed_variables[ code->arg ] ) );
             break;
         }
 
@@ -3463,7 +3463,7 @@
             l = stack_pop( s );
             for( iter = list_begin( l ), end = list_end( l ); iter != end; iter = list_next( iter ) )
             {
- LIST * saved = function_swap_named_variable( function, frame, list_item( iter ), list_copy( L0, value ) );
+ LIST * saved = function_swap_named_variable( function, frame, list_item( iter ), list_copy( value ) );
                 stack_push( s, saved );
             }
             list_free( value );
@@ -3540,7 +3540,7 @@
 
                 for ( ; vars_iter != vars_end; vars_iter = list_next( vars_iter ) )
                     t->settings = addsettings( t->settings, VAR_SET, list_item( vars_iter ),
- list_copy( L0, value ) );
+ list_copy( value ) );
             }
             list_free( vars );
             list_free( targets );
@@ -3561,7 +3561,7 @@
 
                 for ( ; vars_iter != vars_end; vars_iter = list_next( vars_iter ) )
                     t->settings = addsettings( t->settings, VAR_APPEND, list_item( vars_iter ),
- list_copy( L0, value ) );
+ list_copy( value ) );
             }
             list_free( vars );
             list_free( targets );
@@ -3582,7 +3582,7 @@
 
                 for ( ; vars_iter != vars_end; vars_iter = list_next( vars_iter ) )
                     t->settings = addsettings( t->settings, VAR_DEFAULT, list_item( vars_iter ),
- list_copy( L0, value ) );
+ list_copy( value ) );
             }
             list_free( vars );
             list_free( targets );
@@ -3596,19 +3596,19 @@
 
         case INSTR_SET:
         {
- function_set_variable( function, frame, code->arg, list_copy( L0, stack_top( s ) ) );
+ function_set_variable( function, frame, code->arg, list_copy( stack_top( s ) ) );
             break;
         }
 
         case INSTR_APPEND:
         {
- function_append_variable( function, frame, code->arg, list_copy( L0, stack_top( s ) ) );
+ function_append_variable( function, frame, code->arg, list_copy( stack_top( s ) ) );
             break;
         }
 
         case INSTR_DEFAULT:
         {
- function_default_variable( function, frame, code->arg, list_copy( L0, stack_top( s ) ) );
+ function_default_variable( function, frame, code->arg, list_copy( stack_top( s ) ) );
             break;
         }
 
@@ -3617,7 +3617,7 @@
             LIST * * ptr = &frame->module->fixed_variables[ code->arg ];
             assert( code->arg < frame->module->num_fixed_variables );
             list_free( *ptr );
- *ptr = list_copy( L0, stack_top( s ) );
+ *ptr = list_copy( stack_top( s ) );
             break;
         }
 
@@ -3625,7 +3625,7 @@
         {
             LIST * * ptr = &frame->module->fixed_variables[ code->arg ];
             assert( code->arg < frame->module->num_fixed_variables );
- *ptr = list_append( *ptr, list_copy( L0, stack_top( s ) ) );
+ *ptr = list_append( *ptr, list_copy( stack_top( s ) ) );
             break;
         }
 
@@ -3634,7 +3634,7 @@
             LIST * * ptr = &frame->module->fixed_variables[ code->arg ];
             assert( code->arg < frame->module->num_fixed_variables );
             if ( list_empty( *ptr ) )
- *ptr = list_copy( L0, stack_top( s ) );
+ *ptr = list_copy( stack_top( s ) );
             break;
         }
 
@@ -3644,7 +3644,7 @@
             LIST * vars = stack_pop( s );
             LISTITER iter = list_begin( vars ), end = list_end( vars );
             for( ; iter != end; iter = list_next( iter ) )
- function_set_named_variable( function, frame, list_item( iter ), list_copy( L0, value ) );
+ function_set_named_variable( function, frame, list_item( iter ), list_copy( value ) );
             list_free( vars );
             stack_push( s, value );
             break;
@@ -3656,7 +3656,7 @@
             LIST * vars = stack_pop( s );
             LISTITER iter = list_begin( vars ), end = list_end( vars );
             for( ; iter != end; iter = list_next( iter ) )
- function_append_named_variable( function, frame, list_item( iter ), list_copy( L0, value ) );
+ function_append_named_variable( function, frame, list_item( iter ), list_copy( value ) );
             list_free( vars );
             stack_push( s, value );
             break;
@@ -3668,7 +3668,7 @@
             LIST * vars = stack_pop( s );
             LISTITER iter = list_begin( vars ), end = list_end( vars );
             for( ; iter != end; iter = list_next( iter ) )
- function_default_named_variable( function, frame, list_item( iter ), list_copy( L0, value ) );
+ function_default_named_variable( function, frame, list_item( iter ), list_copy( value ) );
             list_free( vars );
             stack_push( s, value );
             break;

Modified: trunk/tools/build/v2/engine/hcache.c
==============================================================================
--- trunk/tools/build/v2/engine/hcache.c (original)
+++ trunk/tools/build/v2/engine/hcache.c 2012-03-23 18:30:33 EDT (Fri, 23 Mar 2012)
@@ -435,7 +435,7 @@
                         object_str( t->boundname ) );
                 c->age = 0;
                 ++hits;
- l = list_copy( L0, c->includes );
+ l = list_copy( c->includes );
                 return l;
             }
         }
@@ -468,8 +468,8 @@
 
     c->time = t->time;
     c->age = 0;
- c->includes = list_copy( L0, l );
- c->hdrscan = list_copy( L0, hdrscan );
+ c->includes = list_copy( l );
+ c->hdrscan = list_copy( hdrscan );
 
     return l;
 }

Modified: trunk/tools/build/v2/engine/lists.c
==============================================================================
--- trunk/tools/build/v2/engine/lists.c (original)
+++ trunk/tools/build/v2/engine/lists.c 2012-03-23 18:30:33 EDT (Fri, 23 Mar 2012)
@@ -81,8 +81,26 @@
     }
     else
     {
- l = list_copy( l, nl );
- list_free( nl );
+ int l_size = list_length( l );
+ int nl_size = list_length( nl );
+ int size = l_size + nl_size;
+ unsigned bucket;
+ int i;
+
+ bucket = get_bucket( size );
+ /* Do we need to reallocate? */
+ if ( l_size <= ( 1u << (bucket - 1) ) )
+ {
+ LIST * result = list_alloc( size );
+ memcpy( list_begin( result ), list_begin( l ), l_size * sizeof( OBJECT * ) );
+ list_dealloc( l );
+ l = result;
+ }
+
+ l->impl.size = size;
+ memcpy( list_begin( l ) + l_size, list_begin( nl ), nl_size * sizeof( OBJECT * ) );
+ list_dealloc( nl );
+ return l;
     }
 
     return l;
@@ -140,31 +158,21 @@
  * list_copy() - copy a whole list of strings (nl) onto end of another (l).
  */
 
-LIST * list_copy( LIST * l, LIST * nl )
+LIST * list_copy( LIST * l )
 {
- int l_size = list_length( l );
- int nl_size = list_length( nl );
- int size = l_size + nl_size;
- unsigned bucket;
+ int size = list_length( l );
     int i;
+ LIST * result;
 
     if ( size == 0 ) return L0;
 
- bucket = get_bucket( size );
- if ( bucket == 0 || l_size <= ( 1u << (bucket - 1) ) )
- {
- LIST * result = list_alloc( size );
- memcpy( list_begin( result ), list_begin( l ), l_size * sizeof( OBJECT * ) );
- list_dealloc( l );
- l = result;
- }
-
- l->impl.size = size;
- for ( i = 0; i < nl_size; ++i )
+ result = list_alloc( size );
+ result->impl.size = size;
+ for ( i = 0; i < size; ++i )
     {
- list_begin( l )[ i + l_size ] = object_copy( list_begin( nl )[ i ] );
+ list_begin( result )[ i ] = object_copy( list_begin( l )[ i ] );
     }
- return l;
+ return result;
 }
 
 
@@ -221,7 +229,7 @@
         return L0;
 
     len = list_length( l );
- result = list_copy( L0, l );
+ result = list_copy( l );
 
     qsort( list_begin( result ), len, sizeof( OBJECT * ), str_ptr_compare );
 

Modified: trunk/tools/build/v2/engine/lists.h
==============================================================================
--- trunk/tools/build/v2/engine/lists.h (original)
+++ trunk/tools/build/v2/engine/lists.h 2012-03-23 18:30:33 EDT (Fri, 23 Mar 2012)
@@ -80,7 +80,7 @@
 };
 
 LIST * list_append( LIST *l, LIST *nl );
-LIST * list_copy( LIST *l, LIST *nl );
+LIST * list_copy( LIST *l );
 LIST * list_copy_range( LIST *l, LISTITER first, LISTITER last );
 void list_free( LIST *head );
 LIST * list_new( LIST *head, OBJECT *string );

Modified: trunk/tools/build/v2/engine/make1.c
==============================================================================
--- trunk/tools/build/v2/engine/make1.c (original)
+++ trunk/tools/build/v2/engine/make1.c 2012-03-23 18:30:33 EDT (Fri, 23 Mar 2012)
@@ -1020,9 +1020,9 @@
         {
             /* Build cmd: cmd_new consumes its lists. */
             CMD * cmd = cmd_new( rule,
- list_copy( L0, nt ),
+ list_copy( nt ),
                 list_sublist( ns, start, chunk ),
- list_copy( L0, shell ) );
+ list_copy( shell ) );
 
             if ( cmd )
             {
@@ -1044,7 +1044,7 @@
                     );
 
                 /* Tell the user what didn't fit. */
- cmd = cmd_new( rule, list_copy( L0, nt ),
+ cmd = cmd_new( rule, list_copy( nt ),
                     list_sublist( ns, start, chunk ),
                     list_new( L0, object_copy( constant_percent ) ) );
                 fputs( cmd->buf->value, stdout );

Modified: trunk/tools/build/v2/engine/modules/property-set.c
==============================================================================
--- trunk/tools/build/v2/engine/modules/property-set.c (original)
+++ trunk/tools/build/v2/engine/modules/property-set.c 2012-03-23 18:30:33 EDT (Fri, 23 Mar 2012)
@@ -91,12 +91,12 @@
                         list_append(list_new(L0, object_new("property-set")), unique), 0);
         object_free(rulename);
 
- var_set(frame->module, name, list_copy(L0, val), VAR_SET);
+ var_set(frame->module, name, list_copy(val), VAR_SET);
     }
     else
     {
         list_free(unique);
- val = list_copy(L0, val);
+ val = list_copy(val);
     }
     object_free(name);
 

Modified: trunk/tools/build/v2/engine/rules.c
==============================================================================
--- trunk/tools/build/v2/engine/rules.c (original)
+++ trunk/tools/build/v2/engine/rules.c 2012-03-23 18:30:33 EDT (Fri, 23 Mar 2012)
@@ -405,7 +405,7 @@
     SETTINGS * copy = 0;
     SETTINGS * v;
     for ( v = head; v; v = v->next )
- copy = addsettings( copy, VAR_SET, v->symbol, list_copy( L0, v->value ) );
+ copy = addsettings( copy, VAR_SET, v->symbol, list_copy( v->value ) );
     return copy;
 }
 


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