How can I clean array and prevent further reallocation if there's enough space already?
Jack
jckj33 at gmail.com
Sun Feb 7 21:31:11 UTC 2021
How can I do that? I though something like this:
auto arr = [1, 2, 3, 4];
arr = arr[0 .. 0];
arr ~= 6; // does this cause reallocation?
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 thought into setting the length property to 0. Does this free
the memory block of the array? if it did reuse the existing
memory block in further appends, would do what I want
More information about the Digitalmars-d-learn
mailing list