How can I clean array and prevent further reallocation if there's enough space already?

Jack jckj33 at gmail.com
Sun Feb 7 21:40:12 UTC 2021


On Sunday, 7 February 2021 at 21:34:22 UTC, Adam D. Ruppe wrote:
> On Sunday, 7 February 2021 at 21:31:11 UTC, Jack wrote:
>> assumeSafeAppend() wouldn't work in this case because I don't 
>> know the number of items that is going to be added to the 
>> array.
>
> I don't think that matters. assumeSafeAppend seems appropriate 
> for your need.

I think it would be fine except it assumes the number of items of 
the array to doesn't grow, it rather overwritten new elements

from docs:

"Use this only when it is certain there are no elements in use 
beyond the array in the memory block. If there are, those 
elements will be overwritten by appending to this array."



More information about the Digitalmars-d-learn mailing list