memory management of array
Michel Fortin
michel.fortin at michelf.com
Sat Dec 20 03:22:51 PST 2008
On 2008-12-19 17:01:48 -0500, "Bill Baxter" <wbaxter at gmail.com> said:
> In addition to what other people have said, if you know the length the
> array will be eventually you can preallocate by doing this:
>
> float[] arr;
> arr.length = N;
> arr.length = 0;
The downside of reserving this way is that it'll initialize all the
array elements you're reserving with a default value for no reason at
all. I think reserve should be part of the language so we can avoid
this.
--
Michel Fortin
michel.fortin at michelf.com
http://michelf.com/
More information about the Digitalmars-d
mailing list