Saturday, 8 October 2016

Switch statement is prefered over 'If Else' condition?






A switch construct is more easily translated into a jump (or branch) table. This can make switch statement much over efficient than if else when the case labels are close together. 

             The idea is to place a bunch of jump instruction sequentially in memory and then add the value of the program counter this replaces a sequence of comparison instruction with an add operations. 

No comments:

Post a Comment