summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Maria Matejka <mq@ucw.cz>2017-11-29 11:38:01 +0100
committerJan Maria Matejka <mq@ucw.cz>2018-03-13 16:29:33 +0100
commit7c601e6b7b7696b24ce5f5715fa14dbb91c71d6e (patch)
tree9d988668bd97d0fc9b23144c44e31c017c45566a
parent5a14df395053f4094a1e3ebea98e3487cbfc0e63 (diff)
Filter: recursion to loop
It was supposed to do tail-recursion in interpret() but it didn't compile as such. Converting it to loop makes a significant filter performance improvement for flat filters.
-rw-r--r--filter/filter.c10
1 files changed, 3 insertions, 7 deletions
diff --git a/filter/filter.c b/filter/filter.c
index db90941f..85721dbd 100644
--- a/filter/filter.c
+++ b/filter/filter.c
@@ -633,15 +633,13 @@ static struct f_val
interpret(struct f_inst *what)
{
struct symbol *sym;
- struct f_val v1, v2, res, *vp;
+ struct f_val v1, v2, res = { .type = T_VOID }, *vp;
unsigned u1, u2;
int i;
u32 as;
+ for ( ; what; what = what->next) {
res.type = T_VOID;
- if (!what)
- return res;
-
switch(what->fi_code) {
case FI_COMMA:
TWOARGS;
@@ -1510,9 +1508,7 @@ interpret(struct f_inst *what)
default:
bug( "Unknown instruction %d (%c)", what->fi_code, what->fi_code & 0xff);
- }
- if (what->next)
- return interpret(what->next);
+ }}
return res;
}