This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Hashing of "switch/case" selections


On 28 Dec 2000, Andy Walker stated:
> My experience as a programmer is that programs are almost never
> written with switches to more than a few hundred cases.  I personally
> have never seen one.  More than that, and the programmer finds a more
> efficient, more readable, more maintainable solution, and he can do so
> because he has a deep knowledge of the problem that is unavailable to
> the compiler.  My seat-of-pants estimate is that 400 cases is a good,
> maybe even high, maximum for Hash evaluations.  A program containing a
> switch statement with more than 400 cases in it probably has enough
> other severe design problems that it will never be worth running
> anyway.

Like GCC, for instance? insn-attrtab.c contains switches with many, many
cases.

Don't make the error of assuming that all programs are written by
humans.  Automatically generated code can do things that would make any
sane programmer blanch --- but can also occupy hot spots and thus need
optimization.

Massive gotos, insanely vast statically initialized arrays and huge
switch statements are common. Look at yacc-generated output, for
instance.

-- 
`Umbilical cords are weird squishy rubbery things.
 Kinda like clams.' --- Dan Birchall in the Monastery

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]