How fast is D compared to C++?

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Wed Mar 2 14:55:42 PST 2011


On 3/2/11 3:20 PM, Walter Bright wrote:
> dsimcha wrote:
>> == Quote from Walter Bright (newshound2 at digitalmars.com)'s article
>>> bearophile wrote:
>>>> Bekenn:
>>>>
>>>>> The use of ref introduces a level of indirection.
>>>> This is correct. But a minimally decent compiler must be able to
>>>> remove this
>>>> indirection where possible, like here, and produce efficient code.
>>> Having the optimizer remove indirection is rarely possible in C or
>>> C++, due to
>>> aliasing.
>>
>> I'm sure there are tons of nitty-gritty details in implementing
>> something like
>> this properly, but **in principle**, can't the compiler put a runtime
>> check in for
>> aliasing and select the code path based on whether aliasing is present
>> or not?
>> Essentially, you'd have two generated functions, one that handles the
>> aliasing
>> case and one that handles the no-aliasing case.
>
> The check will cost you more than you win!

Often you stand to win a lot, albeit for simple functions (i.e. consider 
memmove).

Andrei


More information about the Digitalmars-d mailing list