[virtmach] Your VM
Mon, 28 May 2001 02:44:24 -0700
> Now I have a question: does any one know for sure
> if an array of function pointers is faster than
> a switch case? I know threaded code is faster but
> is an function pointer array? (will it help the
> cpu cache enough to make a difference?)
Assuming that the switch and array are both dense, i.e.
all or nearly all possible positions in the table are
in use, then it depends on which compiler you are using.
Many compilers will generate an indirect jump through a
table of pointers for a dense switch. Generally, the
compiler can generate better code for this internally
than can be written in source code, so the switch version
is likely to be faster.