Optimize my code =)

Craig Dillabaugh cdillaba at cg.scs.carleton.ca
Fri Feb 14 08:40:30 PST 2014


On Friday, 14 February 2014 at 16:00:09 UTC, Robin wrote:
>
> this(size_t rows, size_t cols) {
> 	this.dim = Dimension(rows, cols);
> 	this.data = new T[this.dim.size];
> 	enum nil = to!T(0);
> 	foreach(ref T element; this.data) element = nil;
> }
>
I am no expert at optimizing D code, so this is a bit of a shot 
in the dark, but does your speed improve at all if you replace:

> 	this.data = new T[this.dim.size];

with:

this.data.length = this.dim.size


More information about the Digitalmars-d-learn mailing list