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

Adam J. Thornton adam at phoenix.Princeton.EDU
Mon Feb 8 23:32:37 CET 1999


On Mon, Feb 08, 1999 at 08:29:46PM -0700, Chris Gray wrote:
>     - emit an inline table containing offsets to the code to be executed.
> 	Table is directly indexed by a multiple of the switch value,
> 	usually with a range-test to handle the default. A variant is
> 	to have branch instructions in the table, and to branch to
> 	the appropriate one which then branches to the final code.

The computed GOTO lives!

My approach would be: write it however it is easiest for you, the author,
to understand.

If it turns out to be unacceptably slow, and if profiling the execution
shows that that *is* the bottleneck (both of which I consider unlikely),
then think about changing it and worry about how your compiler is doing it.

Adam
--
adam at princeton.edu 
"There's a border to somewhere waiting, and a tank full of time." - J. Steinman




More information about the mud-dev-archive mailing list