Setting array length to 0 discards reserved allocation?
safety0ff via Digitalmars-d
digitalmars-d at puremagic.com
Thu Jul 24 16:39:20 PDT 2014
On Thursday, 24 July 2014 at 23:30:13 UTC, Andrew Godfrey wrote:
> Is this a bug? Or am I misunderstanding
> something?
>
You need to use assumeSafeAppend before increasing the length
again to avoid allocating new storage.
The runtime doesn't know that `a` is the only reference to that
array, so increasing the length causes an allocation to avoid
stomping on data.
More information about the Digitalmars-d
mailing list