Properties set/get huge speed difference?

Josh Stern josh_usenet at phadd.net
Mon Oct 9 16:16:45 PDT 2006


On Mon, 09 Oct 2006 12:20:36 -0700, Sean Kelly wrote:


>      void main() {
>          C c = new C();
>          c.doSomething(); // A
>      }
> 
> In the code above, even though a vtbl entry may be generated for 
> doSomething, the compiler may optimize the call at point A by calling 
> C.doSomething directly instead of using a double lookup through C's 
> vtbl.  This can be accomplished because the compiler knows that c must 
> be an instance of C at the call point (thus making the optimization 
> extensible to more complex cases where doSomething really is a virtual 
> function).  I'm not sure if DMD currently performs this optimization 
> however, but my guess would be that it does not.  It's still more 
> important to make DMD as bug-free as possible than it is to optimize 
> corner-cases.

I had all the same thoughts.  For all these reasons, wouldn't it be a good
idea to add "final" methods to the language to give the developer the
necessary tool to optimize this intelligently if they need it?






More information about the Digitalmars-d-learn mailing list