[open-ils-commits] r13166 - trunk/Open-ILS/src/c-apps (scottmk)
svn at svn.open-ils.org
svn at svn.open-ils.org
Thu May 14 17:32:38 EDT 2009
Author: scottmk
Date: 2009-05-14 17:32:33 -0400 (Thu, 14 May 2009)
New Revision: 13166
Modified:
trunk/Open-ILS/src/c-apps/oils_cstore.c
Log:
Performance tweak for HAVING clause:
1. Use a char* for it, not a growing_buffer.
2. Don't allocate it at all when there is no HAVING clause.
This change will eliminate to mallocs and frees for each call.
Modified: trunk/Open-ILS/src/c-apps/oils_cstore.c
===================================================================
--- trunk/Open-ILS/src/c-apps/oils_cstore.c 2009-05-14 17:26:10 UTC (rev 13165)
+++ trunk/Open-ILS/src/c-apps/oils_cstore.c 2009-05-14 21:32:33 UTC (rev 13166)
@@ -3312,7 +3312,7 @@
free(table);
char* order_by_list = NULL;
- growing_buffer* having_buf = buffer_init(128);
+ char* having_buf = NULL;
if (!from_function) {
@@ -3333,7 +3333,6 @@
);
buffer_free( sql_buf );
buffer_free( group_buf );
- buffer_free( having_buf );
if( defaultselhash ) jsonObjectFree( defaultselhash );
free( core_class );
return NULL;
@@ -3361,7 +3360,6 @@
);
}
free(core_class);
- buffer_free(having_buf);
buffer_free(group_buf);
buffer_free(sql_buf);
if (defaultselhash) jsonObjectFree(defaultselhash);
@@ -3373,12 +3371,9 @@
if ( having_hash ) {
// and it's on the the WHERE clause
- char* pred = searchWHERE( having_hash, core_meta, AND_OP_JOIN, ctx );
+ having_buf = searchWHERE( having_hash, core_meta, AND_OP_JOIN, ctx );
- if (pred) {
- buffer_add( having_buf, pred );
- free(pred);
- } else {
+ if( ! having_buf ) {
if (ctx) {
osrfAppSessionStatus(
ctx->session,
@@ -3389,7 +3384,6 @@
);
}
free(core_class);
- buffer_free(having_buf);
buffer_free(group_buf);
buffer_free(sql_buf);
if (defaultselhash) jsonObjectFree(defaultselhash);
@@ -3423,7 +3417,7 @@
);
buffer_free( order_buf );
free(core_class);
- buffer_free(having_buf);
+ free(having_buf);
buffer_free(group_buf);
buffer_free(sql_buf);
if (defaultselhash) jsonObjectFree(defaultselhash);
@@ -3454,7 +3448,7 @@
);
buffer_free( order_buf );
free(core_class);
- buffer_free(having_buf);
+ free(having_buf);
buffer_free(group_buf);
buffer_free(sql_buf);
if (defaultselhash) jsonObjectFree(defaultselhash);
@@ -3475,7 +3469,7 @@
"Invalid class referenced in ORDER BY clause -- see error log for more details"
);
free(core_class);
- buffer_free(having_buf);
+ free(having_buf);
buffer_free(group_buf);
buffer_free(sql_buf);
if (defaultselhash) jsonObjectFree(defaultselhash);
@@ -3495,7 +3489,7 @@
"Invalid field referenced in ORDER BY clause -- see error log for more details"
);
free(core_class);
- buffer_free(having_buf);
+ free(having_buf);
buffer_free(group_buf);
buffer_free(sql_buf);
if (defaultselhash) jsonObjectFree(defaultselhash);
@@ -3513,7 +3507,7 @@
);
buffer_free( order_buf );
free(core_class);
- buffer_free(having_buf);
+ free(having_buf);
buffer_free(group_buf);
buffer_free(sql_buf);
if (defaultselhash) jsonObjectFree(defaultselhash);
@@ -3533,7 +3527,7 @@
);
buffer_free( order_buf );
free(core_class);
- buffer_free(having_buf);
+ free(having_buf);
buffer_free(group_buf);
buffer_free(sql_buf);
if (defaultselhash) jsonObjectFree(defaultselhash);
@@ -3577,7 +3571,7 @@
jsonIteratorFree( class_itr );
buffer_free( order_buf );
free(core_class);
- buffer_free(having_buf);
+ free(having_buf);
buffer_free(group_buf);
buffer_free(sql_buf);
if (defaultselhash) jsonObjectFree(defaultselhash);
@@ -3610,7 +3604,7 @@
jsonIteratorFree( class_itr );
buffer_free( order_buf );
free(core_class);
- buffer_free(having_buf);
+ free(having_buf);
buffer_free(group_buf);
buffer_free(sql_buf);
if (defaultselhash) jsonObjectFree(defaultselhash);
@@ -3630,7 +3624,7 @@
jsonIteratorFree( class_itr );
buffer_free( order_buf );
free(core_class);
- buffer_free(having_buf);
+ free(having_buf);
buffer_free(group_buf);
buffer_free(sql_buf);
if (defaultselhash) jsonObjectFree(defaultselhash);
@@ -3656,7 +3650,7 @@
jsonIteratorFree( order_itr );
jsonIteratorFree( class_itr );
free(core_class);
- buffer_free(having_buf);
+ free(having_buf);
buffer_free(group_buf);
buffer_free(order_buf);
buffer_free(sql_buf);
@@ -3693,7 +3687,7 @@
jsonIteratorFree( order_itr );
jsonIteratorFree( class_itr );
free(core_class);
- buffer_free(having_buf);
+ free(having_buf);
buffer_free(group_buf);
buffer_free(order_buf);
buffer_free(sql_buf);
@@ -3749,7 +3743,7 @@
jsonIteratorFree( class_itr );
buffer_free( order_buf );
free(core_class);
- buffer_free(having_buf);
+ free(having_buf);
buffer_free(group_buf);
buffer_free(sql_buf);
if (defaultselhash) jsonObjectFree(defaultselhash);
@@ -3769,7 +3763,7 @@
jsonIteratorFree( class_itr );
buffer_free( order_buf );
free(core_class);
- buffer_free(having_buf);
+ free(having_buf);
buffer_free(group_buf);
buffer_free(sql_buf);
if (defaultselhash) jsonObjectFree(defaultselhash);
@@ -3802,7 +3796,7 @@
}
free(core_class);
- buffer_free(having_buf);
+ free(having_buf);
buffer_free(group_buf);
buffer_free(order_buf);
buffer_free(sql_buf);
@@ -3825,7 +3819,7 @@
);
buffer_free( order_buf );
free(core_class);
- buffer_free(having_buf);
+ free(having_buf);
buffer_free(group_buf);
buffer_free(sql_buf);
if (defaultselhash) jsonObjectFree(defaultselhash);
@@ -3847,15 +3841,10 @@
free(string);
- if( having_buf ) {
- string = buffer_release(having_buf);
-
- if ( *string ) {
- OSRF_BUFFER_ADD( sql_buf, " HAVING " );
- OSRF_BUFFER_ADD( sql_buf, string );
- }
-
- free(string);
+ if( having_buf && *having_buf ) {
+ OSRF_BUFFER_ADD( sql_buf, " HAVING " );
+ OSRF_BUFFER_ADD( sql_buf, having_buf );
+ free( having_buf );
}
if( order_by_list ) {
More information about the open-ils-commits
mailing list