aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoman Plášil <me@rplasil.name>2017-09-04 19:23:50 +0800
committerRoman Plášil <me@rplasil.name>2017-09-04 19:23:50 +0800
commit071856d31995f665ee9219b3e05510ab83f9f4d8 (patch)
treeb414f9803f3bd68738fd69ccf1b288fe4abc5e2d
parent56d34ecab5eb35c426a6e64b034bf2507761dd09 (diff)
downloadlibquotient-071856d31995f665ee9219b3e05510ab83f9f4d8.tar.gz
libquotient-071856d31995f665ee9219b3e05510ab83f9f4d8.zip
Use move on SyncData
-rw-r--r--connection.cpp9
-rw-r--r--connection.h2
-rw-r--r--jobs/syncjob.h2
3 files changed, 6 insertions, 7 deletions
diff --git a/connection.cpp b/connection.cpp
index 9fc2f85b..27f0a86f 100644
--- a/connection.cpp
+++ b/connection.cpp
@@ -160,7 +160,7 @@ void Connection::sync(int timeout)
auto job = d->syncJob =
callApi<SyncJob>(d->data->lastEvent(), filter, timeout);
connect( job, &SyncJob::success, [=] () {
- onSyncSuccess(job->data());
+ onSyncSuccess(job->takeData());
d->syncJob = nullptr;
emit syncDone();
});
@@ -174,7 +174,7 @@ void Connection::sync(int timeout)
});
}
-void Connection::onSyncSuccess(SyncData &data) {
+void Connection::onSyncSuccess(SyncData &&data) {
d->data->setLastEvent(data.nextBatch());
for( auto&& roomData: data.takeRoomData() )
{
@@ -333,8 +333,7 @@ void Connection::saveState(const QUrl &toFile) {
QJsonObject rooms;
for (auto i : this->roomMap()) {
- QJsonObject roomObj = i->toJson();
- rooms[i->id()] = roomObj;
+ rooms[i->id()] = i->toJson();
}
QJsonObject roomObj;
@@ -372,5 +371,5 @@ void Connection::loadState(const QUrl &fromFile) {
QJsonDocument doc { QJsonDocument::fromJson(data) };
SyncData sync;
sync.parseJson(doc);
- onSyncSuccess(sync);
+ onSyncSuccess(std::move(sync));
}
diff --git a/connection.h b/connection.h
index 0265d92f..ad161d7c 100644
--- a/connection.h
+++ b/connection.h
@@ -151,7 +151,7 @@ namespace QMatrixClient
/**
* Completes loading sync data.
*/
- void onSyncSuccess(SyncData &data);
+ void onSyncSuccess(SyncData &&data);
private:
class Private;
diff --git a/jobs/syncjob.h b/jobs/syncjob.h
index 80cc6735..2ded0df3 100644
--- a/jobs/syncjob.h
+++ b/jobs/syncjob.h
@@ -87,7 +87,7 @@ namespace QMatrixClient
const QString& filter = {},
int timeout = -1, const QString& presence = {});
- SyncData &data() { return d; }
+ SyncData &&takeData() { return std::move(d); }
protected:
Status parseJson(const QJsonDocument& data) override;