mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2025-12-18 06:28:03 -06: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:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user