[open-ils-commits] r12064 - trunk/Open-ILS/src/c-apps

svn at svn.open-ils.org svn at svn.open-ils.org
Wed Feb 4 11:48:52 EST 2009


Author: scottmk
Date: 2009-02-04 11:48:49 -0500 (Wed, 04 Feb 2009)
New Revision: 12064

Modified:
   trunk/Open-ILS/src/c-apps/oils_cstore.c
Log:
In SELECT(): simplify and clarify the logic for building a default
select list.  Also, for a minor performance boost: don't look up the
core fields unless we're actually going to use them.


Modified: trunk/Open-ILS/src/c-apps/oils_cstore.c
===================================================================
--- trunk/Open-ILS/src/c-apps/oils_cstore.c	2009-02-04 16:43:03 UTC (rev 12063)
+++ trunk/Open-ILS/src/c-apps/oils_cstore.c	2009-02-04 16:48:49 UTC (rev 12064)
@@ -2321,7 +2321,6 @@
 
 	// general tmp objects
 	const jsonObject* tmp_const;
-	jsonObject* _tmp = NULL;
 	jsonObject* selclass = NULL;
 	jsonObject* selfield = NULL;
 	jsonObject* snode = NULL;
@@ -2338,7 +2337,6 @@
 
 	// metadata about the core search class
 	osrfHash* core_meta = NULL;
-	osrfHash* core_fields = NULL;
 
 	// punt if there's no core class
 	if (!join_hash || ( join_hash->type == JSON_HASH && !join_hash->size ))
@@ -2401,27 +2399,25 @@
 	growing_buffer* group_buf = buffer_init(128);
 	growing_buffer* having_buf = buffer_init(128);
 
-	if (!from_function) 
-        core_fields = osrfHashGet(core_meta, "fields");
+	if(!from_function) {
 
-	// ... and if we /are/ building the default list, do that
-	if ( (_tmp = jsonObjectGetKey(selhash,core_class)) && !_tmp->size ) {
-		
-		int i = 0;
-		char* field;
+		// If we need to build a default list, do so
+		jsonObject* _tmp = jsonObjectGetKey( selhash, core_class );
+		if ( _tmp && !_tmp->size ) {
 
-        if (!from_function) {
+			int i = 0;
+			char* field;
+			osrfHash* core_fields = osrfHashGet( core_meta, "fields" );
+
     		osrfStringArray* keys = osrfHashKeys( core_fields );
-	    	while ( (field = osrfStringArrayGetString(keys, i++)) ) {
+			while ( (field = osrfStringArrayGetString(keys, i++)) ) {
 		    	if ( strncasecmp( "true", osrfHashGet( osrfHashGet( core_fields, field ), "virtual" ), 4 ) )
-			    	jsonObjectPush( _tmp, jsonNewObject( field ) );
+					jsonObjectPush( _tmp, jsonNewObject( field ) );
     		}
-	    	osrfStringArrayFree(keys);
-        }
-	}
-
-	// Now we build the actual select list
-	if (!from_function) {
+			osrfStringArrayFree(keys);
+		}
+	
+		// Now build the actual select list
 	    int sel_pos = 1;
 	    jsonObject* is_agg = jsonObjectFindPath(selhash, "//aggregate");
 	    first = 1;



More information about the open-ils-commits mailing list