C IF statement efficiency...

Lee Carver lee at ssc-vax.UUCP
Fri Aug 19 03:43:42 AEST 1988


In article <8808171400.AA05122 at ucbvax.Berkeley.EDU>, U23405 at UICVM writes:
| I was wondering if, of the two following program fragments, which one would
| be compiled more efficiently by most C compilers:
| 
|           if (big > small)             if (big > small)
|                return big;                  return big;
|           else                         return small;
|                return small;
| 
| In other words, does a compiler handle IF statements with RETURNs more or less
| efficiently than IF..ELSE statements with RETURNs (or with other statements
| besides RETURN, for that matter) ?

Just to muddy the waters, for this application you can use

	return ( big > small ? big : small )

But, maybe you have a real body of code to execute?



More information about the Comp.lang.c mailing list