From 92c1e510969d671931ed58b8df760231c1c6f63a Mon Sep 17 00:00:00 2001 From: scottmk Date: Sun, 22 Feb 2009 14:30:41 +0000 Subject: [PATCH] In SELECT(): replaced an osrfStringArray with an osrfHashIterator, in order to reduce the number of mallocs and frees when traversing an osrfHash. git-svn-id: svn://svn.open-ils.org/ILS/trunk@12262 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- Open-ILS/src/c-apps/oils_cstore.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/Open-ILS/src/c-apps/oils_cstore.c b/Open-ILS/src/c-apps/oils_cstore.c index 5a8eca8278..2b9a6a6266 100644 --- a/Open-ILS/src/c-apps/oils_cstore.c +++ b/Open-ILS/src/c-apps/oils_cstore.c @@ -2463,22 +2463,23 @@ char* SELECT ( OSRF_BUFFER_ADD_CHAR( select_buf, '*' ); else { - // If we need to build a default list, do so + // If we need to build a default list, prepare to do so jsonObject* _tmp = jsonObjectGetKey( selhash, core_class ); if ( _tmp && !_tmp->size ) { - int i = 0; - char* field; osrfHash* core_fields = osrfHashGet( core_meta, "fields" ); - osrfStringArray* keys = osrfHashKeys( core_fields ); - while ( (field = osrfStringArrayGetString(keys, i++)) ) { - if( ! str_is_true( osrfHashGet( osrfHashGet( core_fields, field ), "virtual" ) ) ) - jsonObjectPush( _tmp, jsonNewObject( field ) ); // not virtual; use it - } - osrfStringArrayFree(keys); + osrfHashIterator* field_itr = osrfNewHashIterator( core_fields ); + osrfHash* field_def; + while( ( field_def = osrfHashIteratorNext( field_itr ) ) ) { + if( ! str_is_true( osrfHashGet( field_def, "virtual" ) ) ) { + // This field is not virtual, so add it to the list + jsonObjectPush( _tmp, jsonNewObject( osrfHashIteratorKey( field_itr ) ) ); + } + } + osrfHashIteratorFree( field_itr ); } - + // Now build the actual select list int sel_pos = 1; jsonObject* is_agg = jsonObjectFindPath(selhash, "//aggregate"); -- 2.11.0