|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r83826 - in trunk/tools/build/v2: build engine/modules
From: steven_at_[hidden]
Date: 2013-04-09 18:16:37
Author: steven_watanabe
Date: 2013-04-09 18:16:35 EDT (Tue, 09 Apr 2013)
New Revision: 83826
URL: http://svn.boost.org/trac/boost/changeset/83826
Log:
Make property-set.get a native-rule. Use a binary search instead of creating a hash table. Reduces memory usage by 20% in trunk/status.
Text files modified:
trunk/tools/build/v2/build/property-set.jam | 4 ++
trunk/tools/build/v2/engine/modules/property-set.c | 78 ++++++++++++++++++++++++++++++++++++++-
2 files changed, 80 insertions(+), 2 deletions(-)
Modified: trunk/tools/build/v2/build/property-set.jam
==============================================================================
--- trunk/tools/build/v2/build/property-set.jam (original)
+++ trunk/tools/build/v2/build/property-set.jam 2013-04-09 18:16:35 EDT (Tue, 09 Apr 2013)
@@ -379,6 +379,10 @@
}
NATIVE_RULE property-set : create ;
+if [ HAS_NATIVE_RULE class_at_property-set : get : 1 ]
+{
+ NATIVE_RULE class_at_property-set : get ;
+}
# Creates a new 'property-set' instance after checking that all properties are
# valid and converting implicit properties into gristed form.
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 2013-04-09 18:16:35 EDT (Tue, 09 Apr 2013)
@@ -190,11 +190,85 @@
}
}
+/* binary search for the property value */
+LIST * property_set_get( FRAME * frame, int flags )
+{
+ OBJECT * varname = object_new( "self.raw" );
+ LIST * props = var_get( frame->module, varname );
+ const char * name = object_str( list_front( lol_get( frame->args, 0 ) ) );
+ size_t name_len = strlen( name );
+ LISTITER begin, end;
+ LIST * result = L0;
+ object_free( varname );
+
+ /* Assumes random access */
+ begin = list_begin( props ), end = list_end( props );
+
+ while ( 1 )
+ {
+ ptrdiff_t diff = (end - begin);
+ LISTITER mid = begin + diff / 2;
+ int res;
+ if ( diff == 0 )
+ {
+ return L0;
+ }
+ res = strncmp( object_str( list_item( mid ) ), name, name_len );
+ if ( res < 0 )
+ {
+ begin = mid + 1;
+ }
+ else if ( res > 0 )
+ {
+ end = mid;
+ }
+ else /* We've found the property */
+ {
+ /* Find the beginning of the group */
+ LISTITER tmp = mid;
+ while ( tmp > begin )
+ {
+ --tmp;
+ res = strncmp( object_str( list_item( tmp ) ), name, name_len );
+ if ( res != 0 )
+ {
+ ++tmp;
+ break;
+ }
+ }
+ begin = tmp;
+ /* Find the end of the group */
+ tmp = mid + 1;
+ while ( tmp < end )
+ {
+ res = strncmp( object_str( list_item( tmp ) ), name, name_len );
+ if ( res != 0 ) break;
+ ++tmp;
+ }
+ end = tmp;
+ break;
+ }
+ }
+
+ for ( ; begin != end; ++begin )
+ {
+ result = list_push_back( result,
+ object_new( object_str( list_item( begin ) ) + name_len ) );
+ }
+
+ return result;
+}
void init_property_set()
{
- char const * args[] = { "raw-properties", "*", 0 };
- declare_native_rule( "property-set", "create", args, property_set_create, 1 );
+ {
+ char const * args[] = { "raw-properties", "*", 0 };
+ declare_native_rule( "property-set", "create", args, property_set_create, 1 );
+ }
+ {
+ char const * args[] = { "feature", 0 };
+ declare_native_rule( "class_at_property-set", "get", args, property_set_get, 1 );
+ }
ps_map_init( &all_property_sets );
}
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