Slow performance compared to C++, ideas?

Walter Bright newshound2 at digitalmars.com
Thu Jun 6 12:35:50 PDT 2013


On 6/6/2013 11:27 AM, Walter Bright wrote:
> On 6/6/2013 11:11 AM, deadalnix wrote:
>> It is also possible to automatically generate code like :
>> if (virtualMethod == givenMethod) {
>>      givenMethod();
>> } else {
>>      virtualMethod();
>> }
>>
>> It sound like it is completely stupid, but in fact, as the compiler know the
>> call you'll do, it can run optimizations.
>
> You're right, that is a valid optimization for virtual methods.

(Also, this is often done as a profile guided optimization, with givenMethod 
being the most often case.)



More information about the Digitalmars-d mailing list