long compile time question

BLM768 blm768 at gmail.com
Sat Oct 27 16:13:11 PDT 2012


On Saturday, 27 October 2012 at 23:07:19 UTC, BLM768 wrote:
>
>>
>> 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().

I just realized that this post is redundant; other posts have 
also mentioned optimization for small structs. That makes two 
relatively dumb posts from me in a day; maybe I should just stop 
for now. :)


More information about the Digitalmars-d-learn mailing list