Appender is ... slow

Philippe Sigaud via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Thu Aug 14 12:29:20 PDT 2014


> I've never really tried to benchmark it, but it was my understanding that
> the idea behind Appender was to use it to create the array when you do that
> via a lot of appending, and then you use it as a normal array and stop using
> Appender.

That's how I use it, yes.

> It sounds like you're trying to use it as a way to manage reusing
> the array, and I have no idea how it works for that.

There is a misunderstanding there: I'm using clear only to flush the
state at the beginning of the computation. The Appender is a class
field, used by the class methods to calculate. If I do not clear it at
the beginning of the methods, I keep appending new results to old
computations, which is not what I want. But really, calling clear is a
minor point: I'm interested in Appender's effect on *one* (long,
concatenation-intensive) computation.

> I've
> never actually benchmarked it for just creating arrays via appending. I'd
> just assumed that it was faster than just using ~=, because that's what it's
> supposedly for. But maybe I just completely misunderstood what the point of
> Appender was.

I don't know. People here keep telling newcomers to use it, but I'm
not convinced by its results. Maybe I'm seeing worse results because
my arrays are do not have millions of elements and Appender shines for
long arrays?


More information about the Digitalmars-d-learn mailing list