Re: vtable performance of important function in multiple inheritance
Ron Natalie wrote:
andrew_nuss@yahoo.com wrote:
The question is: in the declaration of EStreamIntf, does the order of
subclasses listed matter in terms of the vtable performance of the
NextChar() function? Will this impact the performance of the virtual
members of the EObject functions provided by EStream_io and
EStreamIntf?
I can't imagine why it would. Essentially the math is done at compile
time to add the table offset to the vtable pointer to get the virtual
function address.
It depends. On a lot of implementations, if the base class
isn't the first base class listed, the compiler will add
something (a constant) to the this pointer to get the address of
the desired sub-object; that could result in an additional add
instruction.
Of course, compared to the indirection necessary to get the
vtable to begin with, and even the simple test as to whether the
called function has the data immediately available, I rather
doubt that this would be measurable.
Of course, rather than guessing, if it is that important to you, you'll
need to benchmark it (making sure you are using the full optmization
levels of the compiler).
That's the only valid answer, of course. I wouldn't bother even
worrying about it until it was clear that the actual application
was too slow, and that the bottleneck turned around the calls to
NextChar.
--
James Kanze (GABI Software) email:james.kanze@gmail.com
Conseils en informatique orient?e objet/
Beratung in objektorientierter Datenverarbeitung
9 place S?mard, 78210 St.-Cyr-l'?cole, France, +33 (0)1 30 23 00 34
--
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]