Date: Tue, 03 Jun 1997 09:54:25 -0700 From: Bill Currie Subject: Re: Quake vs. Demos To: Mark T Logan Cc: eyal DOT ben-david AT aks DOT com, djgpp AT delorie DOT com Reply-to: billc AT blackmagic DOT tait DOT co DOT nz Message-id: <33944C41.2F68@blackmagic.tait.co.nz> Organization: Tait Electronics NZ MIME-version: 1.0 Content-type: text/plain; charset=us-ascii Content-transfer-encoding: 7bit References: <422564AA DOT 004D330F DOT 00 AT aks DOT com> <19970602 DOT 143604 DOT 7119 DOT 3 DOT fwec AT juno DOT com> Precedence: bulk Mark T Logan wrote: > Not necessarily. It doesn't matter how concise your source code is. If > the > 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 > implement > virtual functions, so it may be that they are faster. Anyone care to > comment? Sure ;) 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 something like 4 or 5 instructions. Yes, this is slower than a pute functions call, but not a lot as ther are all mov's and add's. Bill -- Leave others their otherness.