Appender is ... slow

Philippe Sigaud via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Thu Aug 14 11:55:46 PDT 2014


> 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.

I call .clear() only at the beginning of the computation, to avoid any
strange effects with std.datetime.benchmark (using benchmark with
memoizing functions can lead to strange results if one does not take
care to flush any result between to calls.)
After that initial call to clear, I just append.

The thing is, it's not the first time it happens. For years, I tried
to use Appender to get faster code, to no avail.


btw, I saw your Dconf talk yesterday, nice content! And thanks for
talking about Pegged!
It might interest you to know that the code I'm trying to use Appender
on is a new engine for Pegged, based on GLL parsing, that should be
able to produce a parser for any grammar, even ambiguous ones.


More information about the Digitalmars-d-learn mailing list