Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!csd4.milw.wisc.edu!cs.utexas.edu!uunet!mfci!karzes From: karzes@mfci.UUCP (Tom Karzes) Newsgroups: comp.lang.c Subject: Re: forward references in typedefs Message-ID: <964@m3.mfci.UUCP> Date: 26 Jul 89 22:00:01 GMT References: <55480@tut.cis.ohio-state.edu> <1989Jul20.152935.14872@utzoo.uucp> <24CB9E07.9547@marob.masa.com> <18729@mimsy.UUCP> <686@ftp.COM> Sender: karzes@mfci.UUCP Reply-To: karzes@mfci.UUCP (Tom Karzes) Organization: Multiflow Computer Inc., Branford Ct. 06405 Lines: 15 In article <686@ftp.COM> wjr@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.