Straight Forward Arrays

dhs dhs at email.com
Sun Oct 1 17:13:43 UTC 2023


On Sunday, 1 October 2023 at 13:27:37 UTC, Adam D Ruppe wrote:
> On Sunday, 1 October 2023 at 09:01:53 UTC, dhs wrote:
>> When D creates a dynamic array, it returns a slice. Functions 
>> that add or remove elements begin by asking the memory manager 
>> for the dynamic array that the slice belongs to. Only then can 
>> they go on and add elements.
>
> Why is this a problem? It is convenient and usually works fine.
>
> I use the built in arrays very very often for a lot of things.

It may not be a problem in practice. My concern was performance, 
because each time we add an element to the array, the garbage 
collector has to map the slice to the allocation it belongs to.


More information about the Digitalmars-d-learn mailing list