www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Re: Appending to a dynamic array at specific offset

Joseph Bell Wrote:
 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
Jan 23 2007