T[new]

Lionello Lunesu lionello at lunesu.remove.com
Sun Aug 9 18:43:04 PDT 2009


"Andrei Alexandrescu" <SeeWebsiteForEmail at erdani.org> wrote in message 
news:h5ndt0$1blj$1 at digitalmars.com...
> bearophile wrote:
>> Walter Bright:
>>> Under the hood, a T[new] will be a single pointer to a library defined 
>>> type. This library defined type will likely contain three properties:
>>
>> I have another question: are there some performance penalities in using 
>> such arrays for normal random access operations?
>
> One extra indirection, usually nearby.
>
> Andrei

If the size and capacity get added to the begining of the memory block 
containing the data, only an extra offset is needed. The compiler could emit 
"mov eax, [esi*4 + 8]" or something. Look ma, no extra indirection :)

In fact, this is what .NET does as well, if I'm not mistaken. But then, .NET 
always has an extra indirection because of the movable GC stuff, right?

L. 




More information about the Digitalmars-d mailing list