[open-ils-commits] r13790 - trunk/Open-ILS/src/c-apps (scottmk)
svn at svn.open-ils.org
svn at svn.open-ils.org
Mon Aug 3 12:47:05 EDT 2009
Author: scottmk
Date: 2009-08-03 12:47:01 -0400 (Mon, 03 Aug 2009)
New Revision: 13790
Modified:
trunk/Open-ILS/src/c-apps/oils_cstore.c
Log:
Performance tweak in oils_cstore.c: Recoded two loops to use
osrfHashIterators, instead of creating osrfStringArrays and
traversing them.
This change also plugs a memory leak (we weren't freeing one of
the osrfStringArrays).
Modified: trunk/Open-ILS/src/c-apps/oils_cstore.c
===================================================================
--- trunk/Open-ILS/src/c-apps/oils_cstore.c 2009-08-03 03:02:48 UTC (rev 13789)
+++ trunk/Open-ILS/src/c-apps/oils_cstore.c 2009-08-03 16:47:01 UTC (rev 13790)
@@ -1108,19 +1108,19 @@
}
}
- osrfStringArray* class_list;
- if (foreign_context) {
- class_list = osrfHashKeys( foreign_context );
- osrfLogDebug( OSRF_LOG_MARK, "%d foreign context classes(s) specified", class_list->size);
+ if (foreign_context) {
+ unsigned long class_count = osrfHashGetCount( foreign_context );
+ osrfLogDebug( OSRF_LOG_MARK, "%d foreign context classes(s) specified", class_count);
- if (class_list->size > 0) {
-
- int i = 0;
- char* class_name = NULL;
- while ( (class_name = osrfStringArrayGetString(class_list, i++)) ) {
- osrfHash* fcontext = osrfHashGet(foreign_context, class_name);
+ if (class_count > 0) {
+ osrfHash* fcontext = NULL;
+ osrfHashIterator* class_itr = osrfNewHashIterator( foreign_context );
+ while( (fcontext = osrfHashIteratorNext( class_itr ) ) ) {
+ const char* class_name = osrfHashIteratorKey( class_itr );
+ osrfHash* fcontext = osrfHashGet(foreign_context, class_name);
+
osrfLogDebug(
OSRF_LOG_MARK,
"%d foreign context fields(s) specified for class %s",
@@ -1191,7 +1191,7 @@
);
free(m);
- osrfStringArrayFree(class_list);
+ osrfHashIteratorFree(class_itr);
free(foreign_pkey_value);
jsonObjectFree(param);
@@ -1211,18 +1211,18 @@
foreign_field,
osrfStringArrayGetString(context_org_array, context_org_array->size - 1)
);
- }
+ }
- jsonObjectFree(_fparam);
- }
-
- osrfStringArrayFree(class_list);
- }
- }
+ jsonObjectFree(_fparam);
+ }
- jsonObjectFree(param);
- }
+ osrfHashIteratorFree( class_itr );
+ }
+ }
+ jsonObjectFree(param);
+ }
+
char* context_org = NULL;
char* perm = NULL;
int OK = 0;
@@ -1479,13 +1479,12 @@
buffer_add(val_buf,"VALUES (");
- int i = 0;
int first = 1;
- char* field_name;
- osrfStringArray* field_list = osrfHashKeys( fields );
- while ( (field_name = osrfStringArrayGetString(field_list, i++)) ) {
+ osrfHash* field = NULL;
+ osrfHashIterator* field_itr = osrfNewHashIterator( fields );
+ while( (field = osrfHashIteratorNext( field_itr ) ) ) {
- osrfHash* field = osrfHashGet( fields, field_name );
+ const char* field_name = osrfHashIteratorKey( field_itr );
if( str_is_true( osrfHashGet( field, "virtual" ) ) )
continue;
@@ -1552,6 +1551,7 @@
}
+ osrfHashIteratorFree( field_itr );
OSRF_BUFFER_ADD_CHAR( col_buf, ')' );
OSRF_BUFFER_ADD_CHAR( val_buf, ')' );
More information about the open-ils-commits
mailing list