Multiple return values...
Simen Kjærås
simen.kjaras at gmail.com
Thu Mar 15 16:11:44 PDT 2012
On Thu, 15 Mar 2012 23:44:09 +0100, foobar <foo at bar.com> wrote:
> Is swap usually inlined by the compiler?
This is the body of swap for simple types:
auto tmp = lhs;
lhs = rhs;
rhs = tmp;
For more complex types:
ubyte[T.sizeof] t = void;
auto a = (cast(ubyte*) &lhs)[0 .. T.sizeof];
auto b = (cast(ubyte*) &rhs)[0 .. T.sizeof];
t[] = a[];
a[] = b[];
b[] = t[];
So yeah. If that's not inlined, something's wrong.
More information about the Digitalmars-d
mailing list