Skip to content

Commit

Permalink
Replace some more erase/remove patterns with removeIf
Browse files Browse the repository at this point in the history
Change-Id: I6c6f33450fbfd798e5ef71a8ba18f590581dc3a2
Reviewed-by: Joerg Bornemann <[email protected]>
  • Loading branch information
dangelog committed Jan 10, 2021
1 parent b211148 commit c34c6af
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 12 deletions.
4 changes: 1 addition & 3 deletions examples/network/torrent/torrentclient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1501,9 +1501,7 @@ void TorrentClient::addToPeerList(const QList<TorrentPeer> &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);
}
Expand Down
2 changes: 1 addition & 1 deletion qmake/library/qmakebuiltins.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
5 changes: 1 addition & 4 deletions src/corelib/itemmodels/qsortfilterproxymodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -641,10 +641,7 @@ QList<QPair<int, int>> QSortFilterProxyModelPrivate::proxy_intervals_for_source_
interval.first = interval.second = -1;
}
}
proxy_intervals.erase(
std::remove_if(proxy_intervals.begin(), proxy_intervals.end(),
[](QPair<int, int> &interval) { return interval.first < 0; }),
proxy_intervals.end());
proxy_intervals.removeIf([](QPair<int, int> interval) { return interval.first < 0; });
return proxy_intervals;
}

Expand Down
6 changes: 2 additions & 4 deletions tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down

0 comments on commit c34c6af

Please sign in to comment.