[MUD-Dev] Re: Question on c++ switch optimization, and parsers in general.

Ola Fosheim Grøstad <olag@ifi.uio.no> Ola Fosheim Grøstad <olag@ifi.uio.no>
Mon Feb 8 17:46:50 CET 1999


Ben Greear wrote:

> Basically, I'll have a bunch of classes hashed into an array
> that will contain the keywords mapped to an enum.
>
> Now, I get the enum, and then I need to call the various commands
> that the enum maps to.

Maybe I am interpreting "keywords" wrong here, but if you know the keywords
at compile time then you might want to look into programs that can come up
with a perfect hash-function for you. A perfect hashfunction is a function
that takes a string and returns a unique number for your N keywords in the
range [0..N]. Your unix system (if you use one) probably comes with a
program to generate a perfect hashfunction.

--
Ola Fosheim Groestad,Norway      http://www.stud.ifi.uio.no/~olag/






More information about the mud-dev-archive mailing list