forked from qt-creator/qt-creator
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>
This commit is contained in:
@@ -977,16 +977,21 @@ void ModelManagerInterface::parseLoop(QSet<QString> &scannedPaths,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#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
|
// get list of referenced files not yet in snapshot or in directories already scanned
|
||||||
QStringList importedFiles;
|
QStringList importedFiles;
|
||||||
|
|
||||||
|
// 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);
|
findNewImplicitImports(doc, snapshot, &importedFiles, &scannedPaths);
|
||||||
findNewFileImports(doc, snapshot, &importedFiles, &scannedPaths);
|
findNewFileImports(doc, snapshot, &importedFiles, &scannedPaths);
|
||||||
findNewLibraryImports(doc, snapshot, modelManager, &importedFiles, &scannedPaths,
|
findNewLibraryImports(doc, snapshot, modelManager, &importedFiles, &scannedPaths,
|
||||||
&newLibraries);
|
&newLibraries);
|
||||||
|
}
|
||||||
|
|
||||||
// add new files to parse list
|
// add new files to parse list
|
||||||
for (const QString &file : qAsConst(importedFiles)) {
|
for (const QString &file : qAsConst(importedFiles)) {
|
||||||
|
Reference in New Issue
Block a user