On Thursday, 5 October 2017 at 19:59:48 UTC, Igor Shirkalin wrote:
I want to quickly fill it with my own data and I do not want to waste CPU time to fill it with zeros (or some other value).

You could always just allocate it yourself. Something that large is liable to be accidentally pinned by the GC anyway, so I suggest:

int[] data;
int* dataptr = cast(int*) malloc(SOMETHING * int.sizeof);
if(dataptr is null) throw new Exception("malloc failed");
scope(exit) free(dataptr);
data = dataptr[0 .. SOMETHING];
// work with data normally here


Just keep in mind it is freed at scope exit there, so don't escape slices into it.

Reply via email to