switch (expression)
Karl Heuer
karl at haddock.ISC.COM
Tue Jul 19 02:24:04 AEST 1988
In article <14036 at apple.Apple.COM> lenoil at apple.apple.com.UUCP (Robert Lenoil) writes:
>It's really inefficient to do int comparisons when the actual thing you're
>CASEing on is a byte. I think that the type of the case labels should be
>whatever the type of the switch expression...
This is a Quality of Implementation issue. A good optimizer will notice the
size of the switch parameter, and take appropriate action.
>On a similar note, it annoys me that enums can only be int-valued, when 99%
>of the time they'll fit in a char.
"Each enumerated type shall be compatible with an integer type; the choice of
type is implementation-defined" [Jan88 dpANS, 3.5.2.2]. I believe this allows
the implementation to use bytes for byte-sized enumerations.
Karl W. Z. Heuer (ima!haddock!karl or karl at haddock.isc.com), The Walking Lint
More information about the Comp.std.c
mailing list