From c34c6af3740052617ee9f0876e2720046f0e6bb7 Mon Sep 17 00:00:00 2001 From: Giuseppe D'Angelo Date: Fri, 1 Jan 2021 18:03:02 +0100 Subject: Replace some more erase/remove patterns with removeIf Change-Id: I6c6f33450fbfd798e5ef71a8ba18f590581dc3a2 Reviewed-by: Joerg Bornemann --- examples/network/torrent/torrentclient.cpp | 4 +--- qmake/library/qmakebuiltins.cpp | 2 +- src/corelib/itemmodels/qsortfilterproxymodel.cpp | 5 +---- tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp | 6 ++---- 4 files changed, 5 insertions(+), 12 deletions(-) diff --git a/examples/network/torrent/torrentclient.cpp b/examples/network/torrent/torrentclient.cpp index 6ae5339d28..a63e927e09 100644 --- a/examples/network/torrent/torrentclient.cpp +++ b/examples/network/torrent/torrentclient.cpp @@ -1501,9 +1501,7 @@ void TorrentClient::addToPeerList(const QList &peerList) }; // Remove inactive peers from the peer list until we're below // the max connections count. - d->peers.erase(std::remove_if(d->peers.begin(), d->peers.end(), - firstNInactivePeers), - d->peers.end()); + d->peers.removeIf(firstNInactivePeers); // If we still have too many peers, remove the oldest ones. d->peers.erase(d->peers.begin(), d->peers.begin() + tooMany); } diff --git a/qmake/library/qmakebuiltins.cpp b/qmake/library/qmakebuiltins.cpp index ca4de7b1c6..d1c7b2c328 100644 --- a/qmake/library/qmakebuiltins.cpp +++ b/qmake/library/qmakebuiltins.cpp @@ -1508,7 +1508,7 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::evaluateBuiltinConditional( auto isFrom = [pro](const ProString &s) { return s.sourceFile() == pro; }; - vit->erase(std::remove_if(vit->begin(), vit->end(), isFrom), vit->end()); + vit->removeIf(isFrom); if (vit->isEmpty()) { // When an initially non-empty variable becomes entirely empty, // undefine it altogether. diff --git a/src/corelib/itemmodels/qsortfilterproxymodel.cpp b/src/corelib/itemmodels/qsortfilterproxymodel.cpp index 2777709a80..38417bbba6 100644 --- a/src/corelib/itemmodels/qsortfilterproxymodel.cpp +++ b/src/corelib/itemmodels/qsortfilterproxymodel.cpp @@ -641,10 +641,7 @@ QList> QSortFilterProxyModelPrivate::proxy_intervals_for_source_ interval.first = interval.second = -1; } } - proxy_intervals.erase( - std::remove_if(proxy_intervals.begin(), proxy_intervals.end(), - [](QPair &interval) { return interval.first < 0; }), - proxy_intervals.end()); + proxy_intervals.removeIf([](QPair interval) { return interval.first < 0; }); return proxy_intervals; } diff --git a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp index ebdb3b83c4..e522ec6d05 100644 --- a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp +++ b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp @@ -5204,10 +5204,8 @@ void tst_QWidget::setWindowGeometry_data() const bool skipEmptyRects = (m_platform == QStringLiteral("windows")); for (Rects l : qAsConst(rects)) { - if (skipEmptyRects) { - l.erase(std::remove_if(l.begin(), l.end(), [] (const QRect &r) { return r.isEmpty(); }), - l.end()); - } + if (skipEmptyRects) + l.removeIf([] (const QRect &r) { return r.isEmpty(); }); const QRect &rect = l.constFirst(); for (int windowFlag : windowFlags) { QTest::newRow(QString("%1,%2 %3x%4, flags %5") -- cgit v1.2.3