diff options
author | Rainer Gerhards <rgerhards@adiscon.com> | 2012-09-24 18:31:22 +0200 |
---|---|---|
committer | Rainer Gerhards <rgerhards@adiscon.com> | 2012-09-24 18:31:22 +0200 |
commit | be26632b1e269652992ae6f336c5dd7e2dbec7ab (patch) | |
tree | 5cc36bcf7b227cc392cd19859ab90bd3d24aa920 /grammar | |
parent | 63f41c3efe5d77afbb28d17e00eeae77061b15a5 (diff) | |
download | rsyslog-be26632b1e269652992ae6f336c5dd7e2dbec7ab.tar.gz rsyslog-be26632b1e269652992ae6f336c5dd7e2dbec7ab.tar.xz rsyslog-be26632b1e269652992ae6f336c5dd7e2dbec7ab.zip |
PoC: optimize omdicard --> STOP
Diffstat (limited to 'grammar')
-rw-r--r-- | grammar/rainerscript.c | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/grammar/rainerscript.c b/grammar/rainerscript.c index d0c2dc6b..e5154156 100644 --- a/grammar/rainerscript.c +++ b/grammar/rainerscript.c @@ -45,6 +45,7 @@ #include "srUtils.h" #include "regexp.h" #include "obj.h" +#include "modules.h" DEFobjCurrIf(obj) DEFobjCurrIf(regexp) @@ -2086,6 +2087,19 @@ cnfstmtOptimizeIf(struct cnfstmt *stmt) } } + +static inline void +cnfstmtOptimizeAct(struct cnfstmt *stmt) +{ + action_t *pAct; + + pAct = stmt->d.act; + if(!strcmp((char*)modGetName(stmt->d.act->pMod), "builtin:omdiscard")) { + DBGPRINTF("RainerScript Optimizer: replacing omdiscard by STOP\n"); + stmt->nodetype = S_STOP; + } +} + /* (recursively) optimize a statement */ void cnfstmtOptimize(struct cnfstmt *root) @@ -2109,9 +2123,11 @@ dbgprintf("RRRR: stmtOptimize: stmt %p, nodetype %u\n", stmt, stmt->nodetype); case S_SET: cnfexprOptimize(stmt->d.s_set.expr); break; + case S_ACT: + cnfstmtOptimizeAct(stmt); + break; case S_STOP: - case S_UNSET: - case S_ACT: /* nothing to do */ + case S_UNSET: /* nothing to do */ break; case S_NOP: DBGPRINTF("optimizer error: we see a NOP, how come?\n"); |