virtual method pointer

Steven Schveighoffer schveiguy at yahoo.com
Thu May 3 14:11:57 PDT 2012


On Thu, 03 May 2012 16:57:01 -0400, deadalnix <deadalnix at gmail.com> wrote:

> Le 03/05/2012 22:22, Gor Gyolchanyan a écrit :
>> That workaround is pretty obvious, but I can't afford to make an extra
>> call every time. This event system is supposed to be ultra-fast. Isn't
>> there a way to get to the vtable etry itself?
>
> 1/ Such a trivial thing is surely inlined by any compiler with  
> optimizations on.

I wouldn't count on it.  You can't inline a lambda that is used somewhere  
it's not declared.

> 2/ You can afford a virtual dispatch, but can't afford a function call ?

In my experience, virtual calls are nearly as cheap as normal calls.  But  
doubling the function call setup/teardown/call is not insignificant.  It  
all depends on how much time is spent in the function being called.

> I do think you are in case of premature optimizations here.

This is very likely, it all depends on what you are doing *inside* the  
call.

-Steve


More information about the Digitalmars-d mailing list