# [kirkc6@cs.man.ac.uk: Server Improvement]

"Robert J. Brown" (rj@eli.wariat.org)
Tue, 18 Mar 1997 09:55:18 -0600

- Messages sorted by:[ date ][ thread ][ subject ][ author ]

    ------- Start of forwarded message -------
    Return-Path: moo-cows-errors@parc.xerox.com
    Date: Tue, 18 Mar 1997 03:38:33 PST
    From: chris <kirkc6@cs.man.ac.uk>
    X-Sender: kirkc6@t9
    To: MOO-COWs <moo-cows@parc.xerox.com>
    Subject: Server Improvement
    Mime-Version: 1.0
    Content-Type: TEXT/PLAIN; charset=US-ASCII
    Sender: MOO-Cows-Errors@parc.xerox.com
    Precedence: bulk

    Switch statements in C are meant to be very efficient (although that
    might change from compiler to compiler), and the MOO server uses a switch
    statement to select and execute the MOO language operands.
    As the server spends so much time executing this code (located in the
    function run() in execute.c) any improvement to its performance would
    have a significant impact on the performance of the site.

    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?

    Chris.
    ------- End of forwarded message -------