opEquals(const ref yadaYada)
Steven Schveighoffer
schveiguy at yahoo.com
Tue Dec 15 18:06:05 PST 2009
On Tue, 15 Dec 2009 18:41:30 -0500, Simen kjaeraas
<simen.kjaras at gmail.com> wrote:
> Steven Schveighoffer <schveiguy at yahoo.com> wrote:
>
>> On Mon, 14 Dec 2009 11:44:18 -0500, lws <invalid at email.com> wrote:
>>
>>> On 2009-12-14 07:01:47 -0800, dsimcha <dsimcha at yahoo.com> said:
>>>
>>> 1. Well, stuff like this is good warning to whomever about the
>>> code. Since D is a imperative language, it should at least give you
>>> a warning when you're doing something really inefficient that has a
>>> boilerplate way of accomplishing it that is much faster.
>>
>> It's not faster, it's slower. Passing a reference to an integer or
>> smaller value type is not as efficient passing the value type itself.
>
> This is hardly true on modern architectures. I don't have the numbers on
> it, but even for ints and floats, ref is just as fast (and sometimes
> faster).
I don't see how this is possible. It's a double-indirection vs. a single
indirection when you look at the value.
Yes, it might be inlined, making the lookup just as fast as if it were a
stack variable, but I don't see how it could be faster. I guess it may be
faster if you don't actually use the value in the function.
Besides that point, passing ints or floats by value is not "something
really inefficient" that should be considered a compiler error.
-Steve
More information about the Digitalmars-d
mailing list