On Sunday, 3 February 2013 at 10:32:10 UTC, timotheecour wrote:
One more: Did you try using std.container.Array?
Even if appender is more optimized than naked array appending,
it still has to work with the underlying system.
std.container.Array should be able to do just as well as
vector, or better (D move semnantics).
it's a bit better (see below for timings), with T=22.628 sec
total vs 14s for C++'s std::vector.
Note, I'm not sure how to get address of 1st element in an
std.container.Array (is it even possible??? seems like an
overreaching limitation for the sake of safety in a system
language) so I don't know how to tell the reallocations. But I
guess the scheme is clear (reserve(1+3/2*capacity)). In any
case, there's still a noticable gap with C++. Also, I'm curious
whether you have a reference explaining why 3/2 works better
than 2x (as in std::vector) in resizing?
Yeah: std.container.Array does not allow references to its
internals. D's design is more of a safety first, compared to
C++'s performance first.