Initializing a fixed sized array

Maxim Fomin maxim at maxim-fomin.ru
Sat Jun 1 01:32:11 PDT 2013


On Saturday, 1 June 2013 at 06:28:45 UTC, Jonathan M Davis wrote:
> On Saturday, June 01, 2013 08:16:47 finalpatch wrote:
>> This form is nice:
>> 
>> int[3] x = [1,2,3];
>> 
>> But it is horribly inefficient because it
>> 
>> 1. allocates a dynamic array from the GC
>> 2. writes 1,2,3 to the dynamic array
>> 3. copies the 1,2,3 back to the static array
>
> Are you sure that that still allocates? I thought that that had 
> been fixed. If
> it hasn't, it will be. The issue is completely temporary and 
> not intended to
> be the case long term.
>
> - Jonathan M Davis

Yes, it was a bug and it was fixed. Interesting that when there
was this bug, many didn't know about it. After it was fixed,
there were (and still are) comments warning about this issue.


More information about the Digitalmars-d mailing list