long compile time question
BLM768
blm768 at gmail.com
Sat Oct 27 16:07:18 PDT 2012
>
> In any case, though, separately initializing every member of an
> array is
> silly. That's what a loop is for. That, or a memcpy from an
> immutable
> copy of .init.
I think that the reasoning behind DMD's implementation is that
for small structs, writing out the instructions is more efficient
than a loop or a memcpy(); it's essentially the equivalent of
loop unrolling and function inlining. However, that reasoning
breaks down as soon as the struct's size goes beyond a certain
value.
In my opinion, though, this behavior should be kept for small
structs. For example, if you have a struct that just wraps a
size_t, just generating a move instruction is _way_ faster than a
call to memcpy().
More information about the Digitalmars-d-learn
mailing list