Re: Create uninitialized dynamic array

2017-10-05 Thread Igor Shirkalin via Digitalmars-d-learn
On Thursday, 5 October 2017 at 21:04:30 UTC, Adam D. Ruppe wrote: On Thursday, 5 October 2017 at 19:59:48 UTC, Igor Shirkalin wrote: Is there a pure way to make what I want? oh i almost forgot about this function too: http://dpldocs.info/experimental-docs/std.array.uninitializedArray.1.html

Re: Create uninitialized dynamic array

2017-10-05 Thread Adam D. Ruppe via Digitalmars-d-learn
On Thursday, 5 October 2017 at 19:59:48 UTC, Igor Shirkalin wrote: Is there a pure way to make what I want? oh i almost forgot about this function too: http://dpldocs.info/experimental-docs/std.array.uninitializedArray.1.html import std.array; double[] arr = uninitializedArray!(double[])(100

Re: Create uninitialized dynamic array

2017-10-05 Thread Adam D. Ruppe via Digitalmars-d-learn
On Thursday, 5 October 2017 at 20:52:00 UTC, Igor Shirkalin wrote: Doesn't it mean we have to avoid GC for such large blocks? And what if we need a lot blocks with less sizes? No, it can work, especially if you are on 64 bit. Just if it is trivial I'd malloc it, but if the lifetime is nontrivi

Re: Create uninitialized dynamic array

2017-10-05 Thread Igor Shirkalin via Digitalmars-d-learn
On Thursday, 5 October 2017 at 20:19:15 UTC, Adam D. Ruppe wrote: 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 you

Re: Create uninitialized dynamic array

2017-10-05 Thread Adam D. Ruppe via Digitalmars-d-learn
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

Create uninitialized dynamic array

2017-10-05 Thread Igor Shirkalin via Digitalmars-d-learn
Hello! Preface: I need 1G array of ints (or anything else). Problem: 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). I do like this: void main() { int[] data; // key code: data.length = SOMETHING; // ho