On quarta-feira, 29 de março de 2017 08:44:35 PDT Thiago Macieira wrote: > Ok, so I guess we can easily benchmark this by making the Qt containers > forget about the movable property, then benchmark the load time of a large > application like Qt Creator. Unfortunately, this means recompiling > everything, since containers are inlined everywhere. It's easy (a two-line > change in qtypeinfo.h), but takes times.
Ok, not so easy because QVector does not implement detaching by moves. Here's what it looks like for me: const size_t newSize = size() + std::distance(i1, i2); const bool isTooSmall = newSize > d->allocatedCapacity(); const bool isOverlapping = d->begin() <= i1 && i2 <= d->end(); if (isTooSmall || d->needsDetach() || Q_UNLIKELY(isOverlapping)) { typename Data::ArrayOptions flags = d->detachFlags(); if (isTooSmall) flags |= Data::GrowsForward; DataPointer detached(Data::allocate(d->detachCapacity(newSize), flags)); detached->copyAppend(constBegin(), constEnd()); detached->copyAppend(i1, i2); d.swap(detached); } else { // we're detached and we can just move data around d->copyAppend(i1, i2); } I'd need to insert a third branch, splitting the isTooSmall case from the d->needsDetach() one. Then we could do moves. This needs to be implemented in the other containers too before we can benchmark. Q1: Where's this code which you've pasted? It's QGenericArray https://gitlab.com/thiagomacieira/qtbase/blob/master/src/corelib/tools/ qgenericarray.h#L559 Q2: Where's the handling of movable types? Hidden behind QArrayDataPointer, see your qarraydataops.h for copyAppend. This is actually exception-safe. -- Thiago Macieira - thiago.macieira (AT) intel.com Software Architect - Intel Open Source Technology Center _______________________________________________ Development mailing list Development@qt-project.org http://lists.qt-project.org/mailman/listinfo/development