[Home] [Groups] - Message: [Prev in Group] [Next in Group]
9568: [MUD-Dev] Re: Question on c++ switch optimization, and parsers in general.
[Full Header] [Plain Text]
From: "Adam J. Thornton" <adam@phoenix.Princeton.EDU>
Newsgroups: nu.kanga.list.mud-dev
Date: Mon, 8 Feb 1999 23:32:37 -0500
References: [1]
Organization: Kanga.Nu
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@princeton.edu
"There's a border to somewhere waiting, and a tank full of time." - J. Steinman