forward references in typedefs

Tom Karzes karzes at mfci.UUCP
Thu Jul 27 08:00:01 AEST 1989


In article <686 at ftp.COM> wjr at ftp.UUCP (Bill Rust) writes:
>Excuse me. I am not a compiler writer but even I know that there are
>two ways to implement switches: jump tables and compare and execute
>when equal.

There are more ways to implement switch statements than this.  For example,
if you have a sparse but large set of case values, it may make sense to
use an optimized hash table to look up the branch targets.  Even for the
"compare and execute when equal" case there are several possibilities.
If there are only a couple of values, it makes sense to simply check them
individually and execute the default case when there's no match.  For a
larger set of values, it might make sense to do a binary search (which
of course is log(n)), assuming you didn't want to use an optimized hash
table.  I'm sure there are other possibilites as well, although these
are the ones you're most likely to actually see implemented.



More information about the Comp.lang.c mailing list