T[new] misgivings

Leandro Lucarella llucax at gmail.com
Fri Oct 16 09:05:36 PDT 2009


Andrei Alexandrescu, el 16 de octubre a las 09:12 me escribiste:
> Max Samukha wrote:
> >On Fri, 16 Oct 2009 14:25:44 +0200, Don <nospam at nospam.com> wrote:
> >
> >>Yes, but you could allocate the data immediately after the Array
> >>structure, so you only have one allocation. And in the common
> >>case, where it never exceeds the original capacity, they stay
> >>together and preserve cache locality.
> >>
> >> void *data;   // = &raw_data;
> >> size_t length;
> >> size_t capacity; // = 512
> >> ubyte[512] raw_data;
> >
> >Great! And if the length later exceeds the capacity, try to reallocate
> >in place. If impossible, allocate a new block, copy the data, adjust
> >the data pointer and shrink the original block to the size of the
> >Array struct. Right?
> 
> That's the idea. The only problem that Walter pointed out was that
> moving GCs may have a problem with internal pointers.

GC have to support internal pointers anyways, I don't see how this changes
anything...

-- 
Leandro Lucarella (AKA luca)                     http://llucax.com.ar/
----------------------------------------------------------------------
GPG Key: 5F5A8D05 (F8CD F9A7 BF00 5431 4145  104C 949E BFB6 5F5A 8D05)
----------------------------------------------------------------------
We're rotten fruit
We're damaged goods
What the hell, we've got nothing more to lose
One gust and we will probably crumble
We're backdrifters



More information about the Digitalmars-d mailing list