On Thursday, 13 March 2014 at 19:28:59 UTC, Walter Bright wrote:
On 3/13/2014 1:43 AM, Don wrote:
The worst breaking change in D2, by far, is the prevention of array stomping.

After that change, our code still runs, and produces exactly the same results, but it is so slow that it's completely unusable. This one of the main reasons
we're still using D1.

I didn't know this. I'd like more details - perhaps I can help with how to deal with it.

Our entire codebase assumes that stomping will happen. Simplest example:

T[] dupArray(T)(ref T[] dest, T[] src)
{
    dest.length = src.length;
    if (src.length) {
        dest[] = src[];
    }
    return dest;
}

This is equivalent to dest = src.dup, but if dest was already long enough to contain src, no allocation occurs.

Sure, we can add a call to "assumeSafeAppend()" everywhere. And I mean *everywhere*. Every single instance of array creation or concatentation, without exception. Almost every array in our codebase is affected by this.

Reply via email to