Small Array::addArray() optimisation


#1

adding an ensureAllocatedSize() call line 733 :

template <class OtherArrayType>
void addArray (const OtherArrayType& arrayToAddFrom,
               int startIndex = 0,
               int numElementsToAdd = -1)
{
    const typename OtherArrayType::ScopedLockType lock1 (arrayToAddFrom.getLock());

    {
        const ScopedLockType lock2 (getLock());

        if (startIndex < 0)
        {
            jassertfalse;
            startIndex = 0;
        }

        if (numElementsToAdd < 0 || startIndex + numElementsToAdd > arrayToAddFrom.size())
            numElementsToAdd = arrayToAddFrom.size() - startIndex;

        data.ensureAllocatedSize (numUsed + numElementsToAdd);

        while (--numElementsToAdd >= 0)
            add (arrayToAddFrom.getUnchecked (startIndex++));
    }
}

#2

Good idea! Will have a look shortly…