From aeed7f3bada2cefcb52d4418b5ed76f19980d702 Mon Sep 17 00:00:00 2001 From: Tobias Fella Date: Fri, 24 Dec 2021 14:29:07 +0100 Subject: Cache deviceslist to binary when possible --- lib/connection.cpp | 13 ++++++++++--- 1 file 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()); -- cgit v1.2.3