Appending to a dynamic array at specific offset
renoX
renosky at free.fr
Tue Jan 23 02:36:50 PST 2007
Joseph Bell Wrote:
[cut]
> This does work
> msg.length = 3;
> msg ~= data; // Effectively resize the array back to 3 and then append
>
> I don't know how inefficient the above approach is.
Well if the new data is smaller than the old data, then it is an in place replacement otherwise there is a new allocation and a copy, but this is unavoidable.
You can check it by printing msg.ptr before and after (I've did the check before replying)
As for a better notation, sorry but I don't know enough D to answer.
renoX
More information about the Digitalmars-d
mailing list