diff options
author | Tobias Fella <fella@posteo.de> | 2021-12-24 14:29:07 +0100 |
---|---|---|
committer | Tobias Fella <fella@posteo.de> | 2021-12-24 14:29:07 +0100 |
commit | aeed7f3bada2cefcb52d4418b5ed76f19980d702 (patch) | |
tree | 44502e2036c2a292a9f37e17d66971d17e3d3a8f | |
parent | 31bb962f36c31621b311f1aee654e36ea09e8d77 (diff) | |
download | libquotient-aeed7f3bada2cefcb52d4418b5ed76f19980d702.tar.gz libquotient-aeed7f3bada2cefcb52d4418b5ed76f19980d702.zip |
Cache deviceslist to binary when possible
-rw-r--r-- | lib/connection.cpp | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/lib/connection.cpp b/lib/connection.cpp index 8b9f9688..e28ffb22 100644 --- a/lib/connection.cpp +++ b/lib/connection.cpp @@ -1982,9 +1982,16 @@ void Connection::Private::saveDevicesList() rootObj.insert(QStringLiteral("sync_token"), q->nextBatchToken()); } - - QJsonDocument json { rootObj }; - const auto data = json.toJson(); +#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0) + const auto data = + cacheToBinary + ? QCborValue::fromJsonValue(rootObj).toCbor() + : QJsonDocument(rootObj).toJson(QJsonDocument::Compact); +#else + QJsonDocument json { rootObj }; + const auto data = cacheToBinary ? json.toBinaryData() + : json.toJson(QJsonDocument::Compact); +#endif qCDebug(PROFILER) << "DeviceList generated in" << et; outFile.write(data.data(), data.size()); |