On Friday, 15 August 2014 at 21:24:25 UTC, Jonathan M Davis wrote:
On Friday, 15 August 2014 at 16:48:10 UTC, monarch_dodra wrote:
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*)
Is that because it's able to grab memory from the GC without
actually having to allocate anything? Normally, I would have
expected allocations to far outweigh the cost on extension and
that preallocating would help a lot. But that would be with
malloc or C++'s new rather than the GC, which has already
allocated memory to reuse after it collects garbage.
- Jonathan M Davis
It's mostly just because GC-array appending is slow. A single
operation is itself not that slow, but if you plan to append
10_000 elements, then the total cost will add up. A lot.