From a8d6bb06df5b54fe2b71872e51a488548bd684c2 Mon Sep 17 00:00:00 2001 From: Marco Bubke Date: Tue, 6 Jul 2021 11:39:24 +0200 Subject: [PATCH] QmlDesigner: Avoid writes into the project storage If the values are the same we should avoid writes to the database because they are not so cheap. Also recognize that "IS NOT" is used instead of "<>" because we want to test for null values too. Change-Id: I6699c6c40ad42f5d07910905b10cc7d423373320 Reviewed-by: Thomas Hartmann Reviewed-by: Qt CI Bot --- .../designercore/projectstorage/projectstorage.h | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/plugins/qmldesigner/designercore/projectstorage/projectstorage.h b/src/plugins/qmldesigner/designercore/projectstorage/projectstorage.h index 52d5f210c21..bf2f80790f1 100644 --- a/src/plugins/qmldesigner/designercore/projectstorage/projectstorage.h +++ b/src/plugins/qmldesigner/designercore/projectstorage/projectstorage.h @@ -1072,6 +1072,9 @@ private: static_cast(type.accessSemantics), &type.sourceId); + if (!type.typeId) + type.typeId = selectTypeIdByImportIdAndNameStatement.template value(&type.importId, + type.typeName); upsertNativeType(type.importId, type.typeName, type.typeId); for (const auto &exportedType : type.exportedTypes) @@ -1516,10 +1519,15 @@ public: "INSERT INTO types(importId, name, accessSemantics, sourceId) VALUES(?1, ?2, " "?3, nullif(?4, -1)) ON " "CONFLICT DO UPDATE SET prototypeId=excluded.prototypeId, " - "accessSemantics=excluded.accessSemantics, sourceId=excluded.sourceId RETURNING typeId", + "accessSemantics=excluded.accessSemantics, sourceId=excluded.sourceId WHERE " + "prototypeId iS NOT excluded.prototypeId OR accessSemantics IS NOT " + "excluded.accessSemantics OR " + "sourceId IS NOT excluded.sourceId RETURNING typeId", database}; WriteStatement updatePrototypeStatement{ - "UPDATE types SET prototypeId=?2, prototypeNameId=?3 WHERE typeId=?1", database}; + "UPDATE types SET prototypeId=?2, prototypeNameId=?3 WHERE typeId=?1 AND (prototypeId IS " + "NOT ?2 OR prototypeNameId IS NOT ?3)", + database}; mutable ReadStatement<1> selectTypeIdByExportedNameStatement{ "SELECT typeId FROM typeNames WHERE name=?1 AND kind=1", database}; mutable ReadStatement<1> selectPrototypeIdStatement{ @@ -1553,7 +1561,7 @@ public: database}; WriteStatement upsertTypeNamesStatement{ "INSERT INTO typeNames(importId, name, typeId, kind) VALUES(?1, ?2, ?3, ?4) ON CONFLICT DO " - "UPDATE SET typeId=excluded.typeId", + "UPDATE SET typeId=excluded.typeId WHERE typeId IS NOT excluded.typeId", database}; mutable ReadStatement<1> selectPrototypeIdsStatement{ "WITH RECURSIVE "