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

Chris Gray cg at ami-cg.GraySage.Edmonton.AB.CA
Sun Feb 7 23:10:13 CET 1999


[Jon A. Lambert, replying to Ben Greear:]

 >> So, the question is:  Is that efficient?  Does the compiler
 >> generate code that does better than a linear search down the
 >> case statements?  If not, I can manually hack a sort of n-ary
 >> tree performance into it, but I'd wrather not if I can help it.

 >Instead of the array mapping to enums, why not map to funtion pointers?

Agreed. There doesn't seem to be any reason to go to an enum. If you
need additional information besides a pointer to the handling function,
you can use a pointer to a struct containing the additional info as well
as a pointer to the handling function.

I essentially do that, although I "point to" MUD code rather than
native code.

--
Don't design inefficiency in - it'll happen in the implementation. - me

Chris Gray     cg at ami-cg.GraySage.Edmonton.AB.CA
               http://www.GraySage.Edmonton.AB.CA/~cg




More information about the mud-dev-archive mailing list