lookuptables vs switch(x)

Liam Breck breck at star.ecs.umass.edu
Sun Nov 18 04:29:32 AEST 1990


Hello World,

I need to use one value to get a string from a list of values and
strings about 30 elements long.  I can think of two ways of doing it:
using an array of structures and a loop to search the array for the
desired value or a switch statement with 30 case labels.  Which is
faster?  If I put the switch in its own function how much will that
slow things down?

thanx

Liam Breck



More information about the Comp.lang.c mailing list