[open-ils-commits] r12262 - trunk/Open-ILS/src/c-apps (scottmk)

svn at svn.open-ils.org svn at svn.open-ils.org
Sun Feb 22 09:30:42 EST 2009


Author: scottmk
Date: 2009-02-22 09:30:41 -0500 (Sun, 22 Feb 2009)
New Revision: 12262

Modified:
   trunk/Open-ILS/src/c-apps/oils_cstore.c
Log:
In SELECT(): replaced an osrfStringArray with an osrfHashIterator, in
order to reduce the number of mallocs and frees when traversing an osrfHash.


Modified: trunk/Open-ILS/src/c-apps/oils_cstore.c
===================================================================
--- trunk/Open-ILS/src/c-apps/oils_cstore.c	2009-02-22 06:34:10 UTC (rev 12261)
+++ trunk/Open-ILS/src/c-apps/oils_cstore.c	2009-02-22 14:30:41 UTC (rev 12262)
@@ -2463,22 +2463,23 @@
 		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");



More information about the open-ils-commits mailing list