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:
Chocobo1 2019-08-04 17:05:19 +08:00
parent a3ca277eaf
commit c004a84f84
No known key found for this signature in database
GPG key ID: 210D9C873253A68C

View file

@ -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);
}