Simen kjaeraas wrote:
Steven Schveighoffer <[email protected]> wrote:
On Mon, 14 Dec 2009 11:44:18 -0500, lws <[email protected]> wrote:
On 2009-12-14 07:01:47 -0800, dsimcha <[email protected]> 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).
To return a reference you must allocate the value. And to use the value
you must dereference the reference. All this takes cycles no matter how
modern your architecture is.