Mail Archives: djgpp/1997/06/02/17:56:01
Mark T Logan wrote:
> Not necessarily. It doesn't matter how concise your source code is. If
> compiler implements virtual functions with a lot of conditional jumps,
> then it
You may have been thinging of switch statements.
> doesn't matter what you use. Of course, I don't know how compilers
> virtual functions, so it may be that they are faster. Anyone care to
Virtual functions are imlemented by table lookup. While compiling, the
virtual functions of a class are assigned an index that is used to look
up the functions pointer in the virtual function table. The table also
supports an offset of some sort used to handle inheritance issues
(probably for multiple inheritance as the offset is usually 0 for single
inheritance). When a virtual functions is called, gcc generats
like 4 or 5 instructions. Yes, this is slower than a pute functions
but not a lot as ther are all mov's and add's.
Leave others their otherness.
- Raw text -