Browse Source

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.
adaptive-webui-19844
Chocobo1 5 years ago
parent
commit
c004a84f84
No known key found for this signature in database
GPG Key ID: 210D9C873253A68C
  1. 10
      src/webui/api/apicontroller.cpp

10
src/webui/api/apicontroller.cpp

@ -28,6 +28,8 @@ @@ -28,6 +28,8 @@
#include "apicontroller.h"
#include <algorithm>
#include <QJsonDocument>
#include <QMetaObject>
@ -69,9 +71,13 @@ const DataMap &APIController::data() const @@ -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…
Cancel
Save