Commit 7c601e6b authored by Jan Maria Matejka's avatar Jan Maria Matejka

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.
parent 5a14df39
Pipeline #34322 passed with stages
in 8 minutes and 34 seconds
...@@ -633,15 +633,13 @@ static struct f_val ...@@ -633,15 +633,13 @@ static struct f_val
interpret(struct f_inst *what) interpret(struct f_inst *what)
{ {
struct symbol *sym; struct symbol *sym;
struct f_val v1, v2, res, *vp; struct f_val v1, v2, res = { .type = T_VOID }, *vp;
unsigned u1, u2; unsigned u1, u2;
int i; int i;
u32 as; u32 as;
for ( ; what; what = what->next) {
res.type = T_VOID; res.type = T_VOID;
if (!what)
return res;
switch(what->fi_code) { switch(what->fi_code) {
case FI_COMMA: case FI_COMMA:
...@@ -1510,9 +1508,7 @@ interpret(struct f_inst *what) ...@@ -1510,9 +1508,7 @@ interpret(struct f_inst *what)
default: default:
bug( "Unknown instruction %d (%c)", what->fi_code, what->fi_code & 0xff); bug( "Unknown instruction %d (%c)", what->fi_code, what->fi_code & 0xff);
} }}
if (what->next)
return interpret(what->next);
return res; return res;
} }
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment