QUOTE
So many people have told me"Oh using the switch statment saves clock cycles" and yet I have yet to see it. Those times I looked at the disasssembly the if-else-if versions were shorter and more clearly laid out. So at least I know with the if-else-if method I will understand the assembly if I need to.
The code generated for switch constructs is different.
It doesnt consist of multiple jumps at all.
It just uses ONE JUMP like this:
call [edx + eax*4]
where edx contains the base address of the table which contains addresses for each case, and eax contains integer values.
Now, that's efficient.
I have seen such implementation in disassembled listings of programs compiled with Watcom C++ and Borland C++. Im not sure of VC++ though.