[techtalk] switch function in C (or how to read commandline args?)

Jeff Dike jdike at karaya.com
Wed Jul 4 18:05:21 EST 2001


penguina at cosyn.co.nz said:
> No.
> What this will accomplish is setting the constants
> to be strings, which will then require slow strcmp
> processing as above.  When you tokenize something,
> you come up with a unique *numerical* constant to
> represent a particular string.  You can also have
> several different strings parse to the same token.
> So I could say
> #define HOLA   23
> #define HELLO  23
> #define AMIGO  24
> #define FRIEND 24

Exactly, that's what I meant.  I should have been more clear about that.  
Also, "tokenizing" might be the wrong term, but I don't know of a better one 
offhand.

The basic idea is you convert string constants to numeric constants early, and 
from then on, you get to use nice fast integer operations on them, rather than 
slow string ops.

				Jeff






More information about the Techtalk mailing list