Appender is ... slow

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


On Thursday, 14 August 2014 at 19:29:28 UTC, Philippe Sigaud via 
Digitalmars-d-learn wrote:
> 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,

This is exactly what I propose to change - set `length` to 0 
instead of calling `clear`. That way you will keep using same 
memory chunk simply abandoning its old state at the beginning of 
each computation.


More information about the Digitalmars-d-learn mailing list