Interface vs pure abstract class - speed.

Sean Cavanaugh WorksOnMyMachine at gmail.com
Mon May 13 12:14:40 PDT 2013


On 5/12/2013 12:31 PM, SundayMorningRunner wrote:
> Hello, let's say I have the choice between using an abstract class or an
> interface to declare a "plan", a "template" for the descendants.
>
>  From the dmd compiler point of view, should I use the abstract class
> version (so I guess that for each method call, there will be a few MOV,
> in order to extract the relative address from the vmt before a CALL) or
> the interface version (are the CALL directly performed in this case).
> Are interface faster ? (to get the address used by the CALL).
>
> Thx.

If you actually need speed you would need to use something known as the 
curiously recurring template, and avoid using virtual (as much as 
possible) altogether.



More information about the Digitalmars-d-learn mailing list