On Sunday, 3 February 2013 at 06:02:04 UTC, Ali Çehreli wrote:
Its output is different in that the number of allocations is
less than C++ but the total number of elements that get moved
are more:
[SNIP]
Ali
Note that dynamic arrays are generic containers, so they aren't
exactly optimized for anything. You could try that test with the
"made for appending" std.array.appender: It always tries to
extend without reallocating, and only relocates when the current
memory segment is 100% full.
Furthermore, when it *does* relocate, it use D-style memmove
without calling postblit. Independent of language, and with the
requirement of contiguous memory, I can't really think of a
scheme that could be better than that...?