[open-ils-commits] r12053 - trunk/Open-ILS/src/c-apps
svn at svn.open-ils.org
svn at svn.open-ils.org
Tue Feb 3 17:44:53 EST 2009
Author: scottmk
Date: 2009-02-03 17:44:48 -0500 (Tue, 03 Feb 2009)
New Revision: 12053
Modified:
trunk/Open-ILS/src/c-apps/oils_cstore.c
Log:
Minor tweaks to the SELECT function:
1. Narrowed the scope of the idlClass variable.
2. Made cname const,
3. In the loop for building the column list: eliminated an IDL lookup
for the class name, because we already have it. The IDL stores it
redundantly in two different places, and we don't need to find both.
4. Renamed __column and __alias to _column and _alias. Identifiers
beginning with two underscores are reserved.
Modified: trunk/Open-ILS/src/c-apps/oils_cstore.c
===================================================================
--- trunk/Open-ILS/src/c-apps/oils_cstore.c 2009-02-03 20:58:29 UTC (rev 12052)
+++ trunk/Open-ILS/src/c-apps/oils_cstore.c 2009-02-03 22:44:48 UTC (rev 12053)
@@ -2340,7 +2340,6 @@
// metadata about the core search class
osrfHash* core_meta = NULL;
osrfHash* core_fields = NULL;
- osrfHash* idlClass = NULL;
// punt if there's no core class
if (!join_hash || ( join_hash->type == JSON_HASH && !join_hash->size ))
@@ -2432,9 +2431,9 @@
while ( (selclass = jsonIteratorNext( selclass_itr )) ) {
// round trip through the idl, just to be safe
- idlClass = osrfHashGet( oilsIDL(), selclass_itr->key );
+ const char* cname = selclass_itr->key;
+ osrfHash* idlClass = osrfHashGet( oilsIDL(), cname );
if (!idlClass) continue;
- char* cname = osrfHashGet(idlClass, "classname");
// make sure the target relation is in the join tree
if (strcmp(core_class,cname)) {
@@ -2460,8 +2459,8 @@
jsonIterator* select_itr = jsonNewIterator( selclass );
while ( (selfield = jsonIteratorNext( select_itr )) ) {
- char* __column = NULL;
- char* __alias = NULL;
+ char* _column = NULL;
+ char* _alias = NULL;
// ... if it's a sstring, just toss it on the pile
if (selfield->type == JSON_STRING) {
@@ -2472,7 +2471,7 @@
free(_requested_col);
if (!field) continue;
- __column = strdup(osrfHashGet(field, "name"));
+ _column = strdup(osrfHashGet(field, "name"));
if (first) {
first = 0;
@@ -2489,21 +2488,21 @@
char* pkey = osrfHashGet(idlClass, "primarykey");
char* tname = osrfHashGet(idlClass, "tablename");
- buffer_fadd(select_buf, " oils_i18n_xlate('%s', '%s', '%s', '%s', \"%s\".%s::TEXT, '%s') AS \"%s\"", tname, cname, __column, pkey, cname, pkey, locale, __column);
+ buffer_fadd(select_buf, " oils_i18n_xlate('%s', '%s', '%s', '%s', \"%s\".%s::TEXT, '%s') AS \"%s\"", tname, cname, _column, pkey, cname, pkey, locale, _column);
} else {
- buffer_fadd(select_buf, " \"%s\".%s AS \"%s\"", cname, __column, __column);
+ buffer_fadd(select_buf, " \"%s\".%s AS \"%s\"", cname, _column, _column);
}
} else {
- buffer_fadd(select_buf, " \"%s\".%s AS \"%s\"", cname, __column, __column);
+ buffer_fadd(select_buf, " \"%s\".%s AS \"%s\"", cname, _column, _column);
}
// ... but it could be an object, in which case we check for a Field Transform
} else {
- __column = jsonObjectToSimpleString( jsonObjectGetKeyConst( selfield, "column" ) );
+ _column = jsonObjectToSimpleString( jsonObjectGetKeyConst( selfield, "column" ) );
// again, just to be safe
- osrfHash* field = osrfHashGet( osrfHashGet( idlClass, "fields" ), __column );
+ osrfHash* field = osrfHashGet( osrfHashGet( idlClass, "fields" ), _column );
if (!field) continue;
const char* fname = osrfHashGet(field, "name");
@@ -2514,15 +2513,15 @@
}
if ((tmp_const = jsonObjectGetKeyConst( selfield, "alias" ))) {
- __alias = jsonObjectToSimpleString( tmp_const );
+ _alias = jsonObjectToSimpleString( tmp_const );
} else {
- __alias = strdup(__column);
+ _alias = strdup(_column);
}
if (jsonObjectGetKeyConst( selfield, "transform" )) {
- free(__column);
- __column = searchFieldTransform(cname, field, selfield);
- buffer_fadd(select_buf, " %s AS \"%s\"", __column, __alias);
+ free(_column);
+ _column = searchFieldTransform(cname, field, selfield);
+ buffer_fadd(select_buf, " %s AS \"%s\"", _column, _alias);
} else {
if (locale) {
char* i18n = osrfHashGet(field, "i18n");
@@ -2533,12 +2532,12 @@
char* pkey = osrfHashGet(idlClass, "primarykey");
char* tname = osrfHashGet(idlClass, "tablename");
- buffer_fadd(select_buf, " oils_i18n_xlate('%s', '%s', '%s', '%s', \"%s\".%s::TEXT, '%s') AS \"%s\"", tname, cname, fname, pkey, cname, pkey, locale, __alias);
+ buffer_fadd(select_buf, " oils_i18n_xlate('%s', '%s', '%s', '%s', \"%s\".%s::TEXT, '%s') AS \"%s\"", tname, cname, fname, pkey, cname, pkey, locale, _alias);
} else {
- buffer_fadd(select_buf, " \"%s\".%s AS \"%s\"", cname, fname, __alias);
+ buffer_fadd(select_buf, " \"%s\".%s AS \"%s\"", cname, fname, _alias);
}
} else {
- buffer_fadd(select_buf, " \"%s\".%s AS \"%s\"", cname, fname, __alias);
+ buffer_fadd(select_buf, " \"%s\".%s AS \"%s\"", cname, fname, _alias);
}
}
}
@@ -2565,16 +2564,16 @@
OSRF_BUFFER_ADD_CHAR( group_buf, ',' );
}
- __column = searchFieldTransform(cname, field, selfield);
+ _column = searchFieldTransform(cname, field, selfield);
OSRF_BUFFER_ADD_CHAR(group_buf, ' ');
- OSRF_BUFFER_ADD(group_buf, __column);
- __column = searchFieldTransform(cname, field, selfield);
+ OSRF_BUFFER_ADD(group_buf, _column);
+ _column = searchFieldTransform(cname, field, selfield);
*/
}
}
- if (__column) free(__column);
- if (__alias) free(__alias);
+ if (_column) free(_column);
+ if (_alias) free(_alias);
sel_pos++;
}
More information about the open-ils-commits
mailing list