Appender is ... slow

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


On Thursday, 14 August 2014 at 17:16:42 UTC, Philippe Sigaud 
wrote:
> From time to time, I try to speed up some array-heavy code by 
> using std.array.Appender, reserving some capacity and so on.
>
> It never works. Never. It gives me executables that are maybe 
> 30-50% slower than bog-standard array code.
>
> I don't do anything fancy: I just replace the types, use 
> clear() instead of = null...
>
> Do people here get good results from Appender? And if yes, how 
> are you using it?

I don't know much about Phobos appender implementation details 
but the key thing with reusable buffer is avoid freeing them. 
AFAIR Appender.clear frees the allocated memory but 
`Appender.length = 0` does not, making it possible to just 
overwrite stuff again and again.

Won't promise you anything though!


More information about the Digitalmars-d-learn mailing list