On Friday, 14 February 2014 at 16:56:29 UTC, bearophile wrote:
Craig Dillabaugh:
this.data = new T[this.dim.size];
with:
this.data.length = this.dim.size
It's the same thing.
Bye,
bearophile
Not quite. Setting length will copy over the existing contents of
the array. Using new simply sets every element to .init.
Granted, this.data is empty meaning there's nothing to copy over,
so there's a negligible overhead which may be optimized out by
the compiler anyways.
There's also the uninitializedArray function:
http://dlang.org/phobos/std_array.html#.uninitializedArray