On Tuesday, 18 February 2014 at 08:11:04 UTC, Dicebot wrote:
None of your buffers are on stack in both examples. As those
are dynamic arrays you only get pointer + length as value and
data itself resides on heap in some unknown location.
That.
struct S {}
class C {}
S[] s1; // fat pointer to an array of structs
S[2] s2; // array of two structs, plus a length?
C[] c1; // fat pointer to an array of pointers
C[2] c2; // array of two pointers, plus a length?
I tested some prime sieves both in C++ and D. They worked fastest
with dynamic arrays with a size matching the L1 cache. I presume
the instructions are located elsewhere in the CPU.