On 21/11/2007, Adrian Grajdeanu <[EMAIL PROTECTED]> wrote:
> Nick, do you know for a fact that a C++ complier will optimize for the
> base case of a virtual function? I was under the impression that it
> doesn't know (as in can't determine at compile time) whether the
> function was overwritten or not so it doesn't favor any of the cases. In
> fact I can't even figure how it would if it wanted to optimize an
> indirect function call.
> I'm not trying to start a war, just to clarify my assumption. As it is I
> generally write code using virtual functions that I most often do
> overwrite. If what you say is true, then I am incurring the penalty most
> of the time and that would be bad...

A C++ compiler can make those kinds of assumptions if the object is
created within the current compilation unit and can not be overwritten
from outside it. There are a whole class of optimizations in Java, C
and C++ which can only be applied under these circumstances, which
rely on concepts of scope. Whether or not a particular compiler uses
these optimizations in a particular case is another matter.

cheers
stuart
_______________________________________________
computer-go mailing list
computer-go@computer-go.org
http://www.computer-go.org/mailman/listinfo/computer-go/

Reply via email to