Array length & allocation question

Sean Kelly sean at f4.ca
Thu Jun 8 10:50:14 PDT 2006


Robert Atkinson wrote:
> Quick question concerning Array lengths and memory allocations.
> 
> When an array.length = array.length + 1 (or length - 1) happens, does the system
> only increase (decrease) the memory allocation by 1 [unit] or does it internally
> mantain a buffer and try to minimise the resizing of the array?

The latter.

> I think I can remember seeing posts saying to maintain the buffer yourself and
> other posts saying it was done automatically behind the scenes.

In most cases it's not worth it to try and maintain the buffer yourself. 
  At the very least, you should test both methods and see which is faster.


Sean



More information about the Digitalmars-d-learn mailing list