From: scottmk Date: Sun, 22 Feb 2009 14:30:41 +0000 (+0000) Subject: In SELECT(): replaced an osrfStringArray with an osrfHashIterator, in X-Git-Tag: sprint4-merge-nov22~10744 X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=92c1e510969d671931ed58b8df760231c1c6f63a;p=working%2FEvergreen.git 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 --- 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");