diff options
author | Ulf Hermann <ulf.hermann@qt.io> | 2021-08-13 10:35:49 +0200 |
---|---|---|
committer | Ulf Hermann <ulf.hermann@qt.io> | 2021-08-17 08:55:31 +0000 |
commit | fdaa9b1c10d9a57ca4195bb4337e0cf93c4a356c (patch) | |
tree | 72c4503d947b4397364c991be030ae668d754553 | |
parent | a6917a54842c5c37afcf31c2831c261c51e372ce (diff) |
QmlJS: Destroy local snapshot before modifying its original
If we keep the copy of the snapshot around while it's being modified, we
trigger the copy-on-write mechanism. That is expensive, and destroying
the snapshot afterwards is also expensive.
Task-number: QTCREATORBUG-25899
Change-Id: I9b7e26baf63a4b47c85457e5657fee971a6ce132
Reviewed-by: Fawzi Mohamed <fawzi.mohamed@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
-rw-r--r-- | src/libs/qmljs/qmljsmodelmanagerinterface.cpp | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/src/libs/qmljs/qmljsmodelmanagerinterface.cpp b/src/libs/qmljs/qmljsmodelmanagerinterface.cpp index d0d1d21138..34048e8185 100644 --- a/src/libs/qmljs/qmljsmodelmanagerinterface.cpp +++ b/src/libs/qmljs/qmljsmodelmanagerinterface.cpp @@ -977,16 +977,21 @@ void ModelManagerInterface::parseLoop(QSet<QString> &scannedPaths, } } #endif - // update snapshot. requires synchronization, but significantly reduces amount of file - // system queries for library imports because queries are cached in libraryInfo - const Snapshot snapshot = modelManager->snapshot(); - // get list of referenced files not yet in snapshot or in directories already scanned QStringList importedFiles; - findNewImplicitImports(doc, snapshot, &importedFiles, &scannedPaths); - findNewFileImports(doc, snapshot, &importedFiles, &scannedPaths); - findNewLibraryImports(doc, snapshot, modelManager, &importedFiles, &scannedPaths, - &newLibraries); + + // update snapshot. requires synchronization, but significantly reduces amount of file + // system queries for library imports because queries are cached in libraryInfo + { + // Make sure the snapshot is destroyed before updateDocument, so that we don't trigger + // the copy-on-write mechanism on its internals. + const Snapshot snapshot = modelManager->snapshot(); + + findNewImplicitImports(doc, snapshot, &importedFiles, &scannedPaths); + findNewFileImports(doc, snapshot, &importedFiles, &scannedPaths); + findNewLibraryImports(doc, snapshot, modelManager, &importedFiles, &scannedPaths, + &newLibraries); + } // add new files to parse list for (const QString &file : qAsConst(importedFiles)) { |