aboutsummaryrefslogtreecommitdiff
path: root/jobs
diff options
context:
space:
mode:
authorKitsune Ral <Kitsune-Ral@users.sf.net>2017-09-20 13:00:21 +0900
committerKitsune Ral <Kitsune-Ral@users.sf.net>2017-09-20 13:00:21 +0900
commit7e8c2ee1d00e43aab90030493c31aef0b4467f71 (patch)
treeb4089f11ae8ed5bfc701afd5af99542401cdf3c4 /jobs
parentf42a3090d40343166d2abd198e66fd13e4c7ccd1 (diff)
downloadlibquotient-7e8c2ee1d00e43aab90030493c31aef0b4467f71.tar.gz
libquotient-7e8c2ee1d00e43aab90030493c31aef0b4467f71.zip
Minor optimisations in sync data parsing
Diffstat (limited to 'jobs')
-rw-r--r--jobs/syncjob.cpp13
1 files changed, 8 insertions, 5 deletions
diff --git a/jobs/syncjob.cpp b/jobs/syncjob.cpp
index 062f1b15..78a9e93f 100644
--- a/jobs/syncjob.cpp
+++ b/jobs/syncjob.cpp
@@ -59,27 +59,30 @@ BaseJob::Status SyncJob::parseJson(const QJsonDocument& data)
return d.parseJson(data);
}
-BaseJob::Status SyncData::parseJson(const QJsonDocument &data) {
+BaseJob::Status SyncData::parseJson(const QJsonDocument &data)
+{
QElapsedTimer et; et.start();
+
QJsonObject json = data.object();
nextBatch_ = json.value("next_batch").toString();
// TODO: presence
// TODO: account_data
QJsonObject rooms = json.value("rooms").toObject();
- const struct { QString jsonKey; JoinState enumVal; } roomStates[]
+ static const struct { QString jsonKey; JoinState enumVal; } roomStates[]
{
{ "join", JoinState::Join },
{ "invite", JoinState::Invite },
{ "leave", JoinState::Leave }
};
- for (auto roomState: roomStates)
+ for (const auto& roomState: roomStates)
{
const QJsonObject rs = rooms.value(roomState.jsonKey).toObject();
// We have a Qt container on the right and an STL one on the left
roomData.reserve(static_cast<size_t>(rs.size()));
- for( auto rkey: rs.keys() )
- roomData.emplace_back(rkey, roomState.enumVal, rs[rkey].toObject());
+ for(auto roomIt = rs.begin(); roomIt != rs.end(); ++roomIt)
+ roomData.emplace_back(roomIt.key(), roomState.enumVal,
+ roomIt.value().toObject());
}
qCDebug(PROFILER) << "*** SyncData::parseJson():" << et.elapsed() << "ms";
return BaseJob::Success;