T[new]
Andrei Alexandrescu
SeeWebsiteForEmail at erdani.org
Sun Aug 9 20:37:20 PDT 2009
Lionello Lunesu wrote:
>
> "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 :)
I wish too. The problem is that when you resize the array, the control
block will not refer to the adjacent chunk.
Andrei
More information about the Digitalmars-d
mailing list