Appender is ... slow

Philippe Sigaud via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Fri Aug 15 09:51:19 PDT 2014


On Friday, 15 August 2014 at 16:48:10 UTC, monarch_dodra wrote:
> On Friday, 15 August 2014 at 14:40:36 UTC, Philippe Sigaud 
> wrote:
>> Well, I created a wrapper around a 
>> std.array.uninitializedArray call, to manage the interface I 
>> need
>
> Make sure you don't use that if your type has elaborate 
> construction, or assumes a certain initial state (unless you 
> are actually emplacing your objects of course).

Hmm, what's elaborate construction? They are classes and have 
constructors, of course. I assumed that this produced only null's 
in the array.


>> I thought that, having lots of concatenation in my code, 
>> that'd be a bottleneck. But it appears than pre-allocation 
>> does not give me any speed-up.
>
> If you are using "raw GC arrays", then the "raw" append 
> operation will, outweigh the relocation cost on extension. So 
> pre-allocation wouldn't really help in this situation (though 
> the use of Appender *should*)


OK.


More information about the Digitalmars-d-learn mailing list