mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2024-12-01 01:43:32 +03:00
Avoid redundant actions/conversions
QSet::contains(QSet &) isn't doing anything magical it still has the usual loop inside, so lets just save all the container conversions and do the loop ourselves.
This commit is contained in:
parent
a3ca277eaf
commit
c004a84f84
1 changed files with 8 additions and 2 deletions
|
@ -28,6 +28,8 @@
|
|||
|
||||
#include "apicontroller.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
#include <QJsonDocument>
|
||||
#include <QMetaObject>
|
||||
|
||||
|
@ -69,9 +71,13 @@ const DataMap &APIController::data() const
|
|||
|
||||
void APIController::checkParams(const QSet<QString> &requiredParams) const
|
||||
{
|
||||
const QSet<QString> params {this->params().keys().toSet()};
|
||||
const bool hasAllRequiredParams = std::all_of(requiredParams.cbegin(), requiredParams.cend()
|
||||
, [this](const QString &requiredParam)
|
||||
{
|
||||
return params().contains(requiredParam);
|
||||
});
|
||||
|
||||
if (!params.contains(requiredParams))
|
||||
if (!hasAllRequiredParams)
|
||||
throw APIError(APIErrorType::BadParams);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue