Appender is ... slow
Philippe Sigaud via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Thu Aug 14 13:41:58 PDT 2014
>> 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.
You mean by using the shrinkTo method? (Appender does not have a
length, that's a bit of a bother btw).
I just did, it does not change anything. Too bad.
Heck, my code is simpler to read and use *and* faster by using a
bog-standard D array. I'll keep my array for now :)
More information about the Digitalmars-d-learn
mailing list