MOO-cows Mailing List Archive


[ Re: Server Improvement]

------- Start of forwarded message -------
Date: Tue, 18 Mar 1997 04:54:09 PST
From: "Mark R. Bowyer" <>
Reply-To: "Mark R. Bowyer" <>
Subject: Re: Server Improvement
MIME-Version: 1.0
Content-Type: TEXT/plain; charset=us-ascii
Content-MD5: 2L5z5Y4KV3DMl2IPtbGU0w==
X-Mailer: dtmail 1.2.0 CDE Version 1.2_14 SunOS 5.6 sun4m sparc 
Precedence: bulk

> From: chris <>

> What I would like to put up for discussion is the merits of using a array 
> of pointers to functions instead of a switch statement, as this would 
> eleminate the need to perform a integer search.
> The server already uses enumerations in a switch statement, the 
> enumerations are integer codes which signal performing a addition 
> operation or to pop a value from the stack and so forth. If the code for 
> each operation was inserted into a function, and the address of the 
> function stored in a array then the value of the enumeration could be 
> used as a offset to retrieve the address of the function which should be 
> called. Surely a quick sum is quicker to compute than a search of a 
> integer list?
> Do people think that this would result in a significant performance boost?

So you want:

void* (int, int, int, ...) FunctionArray[100];
(FunctionArray[command])(arg1, arg2, arg3, ...);

Which would be fine, if every single function you call uses exactly the same 
arguements in the same order in each case.  If not you either have to 
special-case those entries, or build a wrapper function for it.  Plus you have 
to assume they'll all return the same type, and that everything they do that 
differs from all the others will be handled within that function.  Then whenever 
you have to add a new command, you have to go through the whole process of 
generating a matching function, which could heavily restrict it's abilities, or 
recode all the others to match...

It sounds like a good idea, but I have to wonder how much engineering would be 
needed to get even a small increase out of it?  I'd be interested to see what 
the people actually coding the MOO have to say, but I'd assume that this has 
been thought of and set aside for good reason...

TC@MOOtiny / Moredhel

|    o o                        ` _ ' |
|    /v\ark R. Bowyer.          /   \                                 |
|    `-'         |
------- End of forwarded message -------

Home | Subject Index | Thread Index