diff --git a/src/widgets/widgets/qmdiarea.cpp b/src/widgets/widgets/qmdiarea.cpp index 7ed790e40f..a0a6e08688 100644 --- a/src/widgets/widgets/qmdiarea.cpp +++ b/src/widgets/widgets/qmdiarea.cpp @@ -161,7 +161,6 @@ #include #include #include -#include #include #include #include @@ -480,17 +479,16 @@ QVector MinOverlapPlacer::getCandidatePlacements(const QSize &size, const */ QVector MinOverlapPlacer::findNonInsiders(const QRect &domain, QVector &source) { - QVector result; - result.reserve(source.size()); + const auto containedInDomain = + [domain](const QRect &srcRect) { return domain.contains(srcRect); }; - QMutableVectorIterator it(source); - while (it.hasNext()) { - const QRect srcRect = it.next(); - if (!domain.contains(srcRect)) { - result << srcRect; - it.remove(); - } - } + const auto firstOut = std::stable_partition(source.begin(), source.end(), containedInDomain); + + QVector result; + result.reserve(source.end() - firstOut); + std::copy(firstOut, source.end(), std::back_inserter(result)); + + source.erase(firstOut, source.end()); return result; }