diff options
Diffstat (limited to 'jobs/basejob.cpp')
-rw-r--r-- | jobs/basejob.cpp | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/jobs/basejob.cpp b/jobs/basejob.cpp index f508026f..0a81ad5c 100644 --- a/jobs/basejob.cpp +++ b/jobs/basejob.cpp @@ -46,7 +46,7 @@ class BaseJob::Private public: // Using an idiom from clang-tidy: // http://clang.llvm.org/extra/clang-tidy/checks/modernize-pass-by-value.html - Private(HttpVerb v, QString endpoint, QUrlQuery q, Data data, bool nt) + Private(HttpVerb v, QString endpoint, QUrlQuery q, Data&& data, bool nt) : verb(v), apiEndpoint(std::move(endpoint)) , requestQuery(std::move(q)), requestData(std::move(data)) , needsToken(nt) @@ -101,8 +101,8 @@ BaseJob::BaseJob(HttpVerb verb, const QString& name, const QString& endpoint, bo { } BaseJob::BaseJob(HttpVerb verb, const QString& name, const QString& endpoint, - const Query& query, const Data& data, bool needsToken) - : d(new Private(verb, endpoint, query, data, needsToken)) + const Query& query, Data&& data, bool needsToken) + : d(new Private(verb, endpoint, query, std::move(data), needsToken)) { setObjectName(name); setExpectedContentTypes({ "application/json" }); @@ -159,9 +159,9 @@ const BaseJob::Data& BaseJob::requestData() const return d->requestData; } -void BaseJob::setRequestData(const BaseJob::Data& data) +void BaseJob::setRequestData(Data&& data) { - d->requestData = data; + std::swap(d->requestData, data); } const QByteArrayList& BaseJob::expectedContentTypes() const @@ -206,10 +206,10 @@ void BaseJob::Private::sendRequest() reply.reset( connection->nam()->get(req) ); break; case HttpVerb::Post: - reply.reset( connection->nam()->post(req, requestData.serialize()) ); + reply.reset( connection->nam()->post(req, requestData.source()) ); break; case HttpVerb::Put: - reply.reset( connection->nam()->put(req, requestData.serialize()) ); + reply.reset( connection->nam()->put(req, requestData.source()) ); break; case HttpVerb::Delete: reply.reset( connection->nam()->deleteResource(req) ); @@ -447,4 +447,3 @@ void BaseJob::setLoggingCategory(LoggingCategory lcf) { d->logCat = lcf; } - |