Appender is ... slow

Dicebot via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Thu Aug 14 13:53:29 PDT 2014


On Thursday, 14 August 2014 at 20:50:37 UTC, Dicebot wrote:
> Oh crap I had std.array.Array in mind which does have `length` 
> exposes. And Appender seems to indeed clear / shrink data in a 
> horrible way:
>
> https://github.com/D-Programming-Language/phobos/blob/master/std/array.d#L2597
> https://github.com/D-Programming-Language/phobos/blob/master/std/array.d#L2611
>
> Wow, this thing is real garbage!

OK, looks like Appender is written to be fully GC-compatible and 
usable with immutable data which kind of explain such 
implementation. But that makes it inherently slow compared to 
plain `Array` which owns its memory and gets it via malloc.


More information about the Digitalmars-d-learn mailing list