long compile time question
Don Clugston
dac at nospam.com
Wed Oct 24 09:04:10 PDT 2012
On 24/10/12 17:39, thedeemon wrote:
> On Wednesday, 24 October 2012 at 03:50:47 UTC, Dan wrote:
>> The following takes nearly three minutes to compile.
>> The culprit is the line bar ~= B();
>> What is wrong with this?
>>
>> Thanks,
>> Dan
>> ----------------
>> struct B {
>> const size_t SIZE = 1024*64;
>> int[SIZE] x;
>> }
>>
>> void main() {
>> B[] barr;
>> barr ~= B();
>> }
>> -----------------
>
> The code DMD generates for initializing the struct does not use loops,
> so it's
> xor ecx, ecx
> mov [eax], ecx
> mov [eax+4], ecx
> mov [eax+8], ecx
> mov [eax+0Ch], ecx
> mov [eax+10h], ecx
> mov [eax+14h], ecx
> mov [eax+18h], ecx
> mov [eax+1Ch], ecx
> mov [eax+20h], ecx
> mov [eax+24h], ecx
> mov [eax+28h], ecx
> mov [eax+2Ch], ecx
> mov [eax+30h], ecx
> mov [eax+34h], ecx
> mov [eax+38h], ecx
> ...
>
> So your code creates a lot of work for the compiler.
That's incredibly horrible, please add to bugzilla.
More information about the Digitalmars-d-learn
mailing list