Impressed with Appender - Is there design/implementation description?

Anonymouse via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Tue Dec 6 05:19:22 PST 2016


On Tuesday, 6 December 2016 at 10:52:44 UTC, thedeemon wrote:
> It's rather simple, just take a look at its source code in 
> std.array.
> It's an ordinary linear array partially filled with your data.

[...]

> 2. Up until 4 KB it reallocates when growing, but after 4 KB 
> the array lives in a larger pool of memory where it can often 
> grow a lot without reallocating, so in many scenarios where 
> other allocations do not interfere, the data array of appender 
> grows in place without copying any data, thanks to GC.extend() 
> method.

I always assumed it kept its own manually allocated array on a 
malloc heap :O

Hence a practice of using .dup and .idup on the .data member when 
you're happy with the result?


More information about the Digitalmars-d-learn mailing list