summaryrefslogtreecommitdiffstats
path: root/grammar
diff options
context:
space:
mode:
authorRainer Gerhards <rgerhards@adiscon.com>2012-09-25 17:22:22 +0200
committerRainer Gerhards <rgerhards@adiscon.com>2012-09-25 17:22:22 +0200
commiteb18d9b23248732da3cba2b170ddc271ae7ec346 (patch)
tree2aefd8f06f741032f656552b4758c7f5d560e573 /grammar
parent87fb978c809fbc0432f5216251fbc7782d574f97 (diff)
downloadrsyslog-eb18d9b23248732da3cba2b170ddc271ae7ec346.tar.gz
rsyslog-eb18d9b23248732da3cba2b170ddc271ae7ec346.tar.xz
rsyslog-eb18d9b23248732da3cba2b170ddc271ae7ec346.zip
slight optimization of == in string comparisons
Diffstat (limited to 'grammar')
-rw-r--r--grammar/rainerscript.c26
1 files changed, 17 insertions, 9 deletions
diff --git a/grammar/rainerscript.c b/grammar/rainerscript.c
index 04072cdb..035b017d 100644
--- a/grammar/rainerscript.c
+++ b/grammar/rainerscript.c
@@ -1066,23 +1066,31 @@ cnfexprEval(struct cnfexpr *expr, struct var *ret, void* usrptr)
* places flagged with "CMP" need to be changed.
*/
case CMP_EQ:
+ /* this is optimized in regard to right param as a PoC for all compOps
+ * So this is a NOT yet the copy template!
+ */
cnfexprEval(expr->l, &l, usrptr);
- cnfexprEval(expr->r, &r, usrptr);
ret->datatype = 'N';
if(l.datatype == 'S') {
- if(r.datatype == 'S') {
- ret->d.n = !es_strcmp(l.d.estr, r.d.estr); /*CMP*/
+ if(expr->r->nodetype == 'S') {
+ ret->d.n = !es_strcmp(l.d.estr, ((struct cnfstringval*)expr->r)->estr); /*CMP*/
} else {
- n_l = var2Number(&l, &convok_l);
- if(convok_l) {
- ret->d.n = (n_l == r.d.n); /*CMP*/
+ cnfexprEval(expr->r, &r, usrptr);
+ if(r.datatype == 'S') {
+ ret->d.n = !es_strcmp(l.d.estr, r.d.estr); /*CMP*/
} else {
- estr_r = var2String(&r, &bMustFree);
- ret->d.n = !es_strcmp(l.d.estr, estr_r); /*CMP*/
- if(bMustFree) es_deleteStr(estr_r);
+ n_l = var2Number(&l, &convok_l);
+ if(convok_l) {
+ ret->d.n = (n_l == r.d.n); /*CMP*/
+ } else {
+ estr_r = var2String(&r, &bMustFree);
+ ret->d.n = !es_strcmp(l.d.estr, estr_r); /*CMP*/
+ if(bMustFree) es_deleteStr(estr_r);
+ }
}
}
} else {
+ cnfexprEval(expr->r, &r, usrptr);
if(r.datatype == 'S') {
n_r = var2Number(&r, &convok_r);
if(convok_r) {