Avoid deallocate empty arrays?
IGotD-
nise at nise.com
Thu Dec 17 16:48:11 UTC 2020
On Thursday, 17 December 2020 at 16:46:47 UTC, Q. Schroll wrote:
> On Thursday, 17 December 2020 at 16:11:37 UTC, IGotD- wrote:
>> It's common using arrays for buffering
>
> Outside of CTFE, use an Appender.¹ Unless you're having a
> const/immutable element type, Appender can shrink and reuse
> space.² If you have, reallocation is necessary anyway not to
> break const/immutable' guarantees.
>
> ¹ https://dlang.org/phobos/std_array.html#appender
> ² https://dlang.org/phobos/std_array.html#.Appender.clear
Thank you, I will try this one out.
More information about the Digitalmars-d-learn
mailing list