[open-ils-commits] r13798 - trunk/Open-ILS/src/c-apps (scottmk)
svn at svn.open-ils.org
svn at svn.open-ils.org
Wed Aug 5 14:58:25 EDT 2009
Author: scottmk
Date: 2009-08-05 14:58:20 -0400 (Wed, 05 Aug 2009)
New Revision: 13798
Modified:
trunk/Open-ILS/src/c-apps/oils_cstore.c
Log:
In oils_cstore.c, function searchWHERE(): rewrote a loop to use an
index instead of a jsonIterator, to traverse a jsonObject that is
known to be a JSON_ARRAY. This change avoids the malloc and
free required to create and destroy a jsonIterator.
Modified: trunk/Open-ILS/src/c-apps/oils_cstore.c
===================================================================
--- trunk/Open-ILS/src/c-apps/oils_cstore.c 2009-08-05 12:42:12 UTC (rev 13797)
+++ trunk/Open-ILS/src/c-apps/oils_cstore.c 2009-08-05 18:58:20 UTC (rev 13798)
@@ -2550,19 +2550,18 @@
int first = 1;
if ( search_hash->type == JSON_ARRAY ) {
osrfLogDebug(OSRF_LOG_MARK, "%s: In WHERE clause, condition type is JSON_ARRAY", MODULENAME);
- jsonIterator* search_itr = jsonNewIterator( search_hash );
- if( !jsonIteratorHasNext( search_itr ) ) {
+ if( 0 == search_hash->size ) {
osrfLogError(
OSRF_LOG_MARK,
"%s: Invalid predicate structure: empty JSON array",
MODULENAME
);
- jsonIteratorFree( search_itr );
buffer_free( sql_buf );
return NULL;
}
- while ( (node = jsonIteratorNext( search_itr )) ) {
+ unsigned long i = 0;
+ while((node = jsonObjectGetIndex( search_hash, i++ ) )) {
if (first) {
first = 0;
} else {
@@ -2574,7 +2573,6 @@
char* subpred = searchWHERE( node, class_info, opjoin_type, ctx );
if( ! subpred ) {
- jsonIteratorFree( search_itr );
buffer_free( sql_buf );
return NULL;
}
@@ -2582,7 +2580,6 @@
buffer_fadd(sql_buf, "( %s )", subpred);
free(subpred);
}
- jsonIteratorFree(search_itr);
} else if ( search_hash->type == JSON_HASH ) {
osrfLogDebug(OSRF_LOG_MARK, "%s: In WHERE clause, condition type is JSON_HASH", MODULENAME);
More information about the open-ils-commits
mailing list