Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

help - performance improvements

if i have a line of code like this:

if(a=b,1,

if(c=f,2,

if(c=g,3,4)))

my ?: if first condition is true (i.e.a=b) does the engine (parser) still waste it's time and slow stuff down by checking the remaining condiions?

21 Replies
Not applicable
Author

Hi there,

I've had that problem as well. Use strings and evaluate the result works fine as a workaround when using CPU costly expressions. Ex:

If(a=1,

     <expression 1>,

If(a=2,

     <expression 2>,

If(a=3,

     <expression 3>,

//else

     <expression 4>

)))

you may convert every single expression to its string equivalent and $ at the end:

$(=

If(a=1,

     <stringified expression 1>,

If(a=2,

     <stringified expression 2>,

If(a=3,

     <stringified expression 3>,

//else

     <stringified expression 4>

)))

)

What you win: Only evaluate four strings (instead of four costly expressions) and only one costly expression instead of four.

jeck876
Contributor
Contributor

How do you feel about this approach?

https://www.infinityinsight.com/blog/?p=284