Quick question...
Used correctly neither is really faster. Once you hit machine code it all turns into conditional branches and jumps anyway. However, I''m guessing switch statements are more idiot proof from a performance standpoint (not a program correctness standpoint.)
Ok, the following code:
Contains the same number of branches and jumps as the functionally equivalent:
Use which ever works best for you at the time. It''s all the same to the clam.
switch (c) { case 1: a = 1; break; case 2: b = 1; break; default: c = 1;}
Contains the same number of branches and jumps as the functionally equivalent:
if (c == 1) { a = 1;} else if (c == 2) { b = 1;} else { c = 1;}
Use which ever works best for you at the time. It''s all the same to the clam.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement