I know that when source code is compiled, the compiler treats if
/elseif
/else
and switch
statements differently making switch statements at least as efficient as a corresponding if
/elseis
/else
and most often more efficient. This is usually done by building a jump-table at compile time that is utilized at runtime. However, for interpreted languages (not compiled) is there any significant efficiency increase when using a switch
statement? Surely an interpreter cannot pre-build a jump-table to increase the switch
statement's efficiency.
Do interpreters handle switch
statements in a way that increases a switch
statement's efficiency compared to a corresponding set of if
/elseif
/else
statements?