Quote:
Originally Posted by 12171217
From what I remember reading, in GS2, the only proper time to use the switch statement is when you want to take advantage of falling through, as it's a less efficient than standard if-than-else.
|
Hey Downsider,
Although I don't claim to have any knowledge of the specific Bison language parser Stefan created nor any of its specific optimizations, in terms of switch statements in general:
A switch statement can always perform at least as well as a logically equivalent if statement.
A switch statement can perform better than an if statement when the range of values of the switch statement are sufficiently close enough to get compiled to a branch table.
I doubt that optimization has been made in GS2 though, so they are most likely equivalent in terms of performance.