Array length & allocation question
Derek Parnell
derek at psych.ward
Thu Jun 8 14:52:52 PDT 2006
On Fri, 09 Jun 2006 05:33:33 +1000, Chris Nicholson-Sauls
<ibisbasenji at gmail.com> wrote:
> Now, what I didn't test but probably should have, was the effect of
> "pre-allocating" the array by setting the .length to a large value and
> then back to zero, expanding the behind-the-scenes capacity of the
> array. I'm betting in that case the IndexAssign would be the faster.
Not if you set it back to zero. If you do that, D also deallocates the
RAM. Setting its length back to 1 however is okay it that the allocated
RAM stays allocated to the array. This means that the first element is
just a dummy to get around the 'bug'.
--
Derek Parnell
Melbourne, Australia
More information about the Digitalmars-d-learn
mailing list