Which is better?

ix269 at sdcc6.UUCP ix269 at sdcc6.UUCP
Wed Dec 19 20:23:09 AEST 1984


fig()

Might it be noted that if-else pairs are accepted as one statement?
Break is a jump (not machine phrase) out of the switch, so the big
question ends up being will your optimizer discover that one of the 
conditionals is jumping twice (if-else as aversed to if-break-break)?
The source code for the if-else is better looking, and perhaps even
the cost of an extra jump might not be worth the ugliness (unless this
is a kernal ugly).  This leaves things in a different light than merely 
style, but welcome to a higher level language :-).

switch (A) {
	case 0:
		if (B) {
			/* this */
		break;
		}
		/* else */
		break;
	case 1:
		if (B) {
			/* this */
		} else {
			/* that */
		}
		break;
}



More information about the Comp.lang.c mailing list