mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-07-12 16:23:07 -07:00
Improve removeIf() to support set types
We can now replace QMutable*Iterator by removeIf() which usage is more consistent with other algorithm functions.
This commit is contained in:
parent
4ed8b31641
commit
c6f3da1097
7 changed files with 60 additions and 31 deletions
|
@ -32,7 +32,6 @@
|
|||
|
||||
#include <algorithm>
|
||||
|
||||
#include <QMutableListIterator>
|
||||
#include <QNetworkProxy>
|
||||
#include <QSslCipher>
|
||||
#include <QSslConfiguration>
|
||||
|
@ -40,6 +39,7 @@
|
|||
#include <QStringList>
|
||||
#include <QTimer>
|
||||
|
||||
#include "base/algorithm.h"
|
||||
#include "base/utils/net.h"
|
||||
#include "connection.h"
|
||||
|
||||
|
@ -119,14 +119,14 @@ void Server::removeConnection(Connection *connection)
|
|||
|
||||
void Server::dropTimedOutConnection()
|
||||
{
|
||||
QMutableSetIterator<Connection *> i(m_connections);
|
||||
while (i.hasNext()) {
|
||||
Connection *connection = i.next();
|
||||
if (connection->hasExpired(KEEP_ALIVE_DURATION)) {
|
||||
connection->deleteLater();
|
||||
i.remove();
|
||||
}
|
||||
}
|
||||
Algorithm::removeIf(m_connections, [](Connection *connection)
|
||||
{
|
||||
if (!connection->hasExpired(KEEP_ALIVE_DURATION))
|
||||
return false;
|
||||
|
||||
connection->deleteLater();
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
bool Server::setupHttps(const QByteArray &certificates, const QByteArray &privateKey)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue