any news on const/invariant?
Regan Heath
regan at netmail.co.nz
Tue Nov 27 03:31:45 PST 2007
Regan Heath wrote:
> Are you saying that when D extends an array buffer, and there is no
> space to extend in place, it always creates a 2nd copy of the data and
> leaves the original copy untouched?
Seems like you were right about this. This seems to be the code in
internal\gc\gc.d
if (newlength > p.length)
{
size_t size = p.length * sizeelem;
size_t cap = _gc.capacity(p.data);
if (cap <= newsize)
{
if (cap >= 4096)
{ // Try to extend in-place
auto u = _gc.extend(p.data, (newsize + 1) - cap, (newsize + 1) - cap);
if (u)
{
goto L1;
}
}
newdata = cast(byte *)_gc.malloc(newsize + 1);
newdata[0 .. size] = p.data[0 .. size];
if (!(ti.next.flags() & 1))
_gc.hasNoPointers(newdata);
}
L1:
newdata[size .. newsize] = 0;
}
Regan
More information about the Digitalmars-d
mailing list