On 12/18/14 5:27 PM, zeljkog wrote:
On 18.12.14 14:50, Steven Schveighoffer wrote:
I wonder how your code compares to this:

void append(T)(ref T[] arr, T[] args...)
{
     arr ~= args;
}

This is ~20% slower for ints, but it difference  increases for bigger structs.


This is surprising to me. I would expect especially ints to be faster. In reality, there is no difference between arr ~= args and arr.length += args.length, and then copying, it's just how you do the copying. Perhaps it's the call to memcpy in the runtime that is slower than looping.

Did you compile both tests with the same command line parameters?

-Steve

Reply via email to