@xianc78 @beardalaxy Calculation is what CPUs do best. Jumping across code memory in a way that makes it hard for the compiler, the cache, and CPU to optimise around however isn't
@xianc78 @beardalaxy Knowing what is going to be faster with todays hypercomplex hardware is a guessing game at best
In either case, it's the wrong point to make. Write sane, readable, maintainable code first. Optimise then only later if it is clear there is a reason to. The compiler will usually do a better job of it anyway
@beardalaxy When you have a bunch of if-statements like this, it's probably better to have an array or dictionary of function pointers because the CPU can just go to the address of the first value of the array + the offset and then call the function based on the address of the function in the table. On the other hand, if-statements require the CPU to repeatedly calculate conditions which is much less efficient.