From 753bf8a73607fb5b5ee27584b6277ce359b27b8b Mon Sep 17 00:00:00 2001 From: Jochen Becher Date: Sat, 13 Jan 2018 12:45:26 +0100 Subject: [PATCH] ModelEditor: Improve performance of component model creation Change-Id: I93ca27fc14692979314be90c0230d2672de66f04 Reviewed-by: Tobias Hunger --- src/plugins/modeleditor/componentviewcontroller.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/plugins/modeleditor/componentviewcontroller.cpp b/src/plugins/modeleditor/componentviewcontroller.cpp index c790fe64dd4..52501649cd8 100644 --- a/src/plugins/modeleditor/componentviewcontroller.cpp +++ b/src/plugins/modeleditor/componentviewcontroller.cpp @@ -133,6 +133,7 @@ private: private: qmt::ModelController *m_modelController = nullptr; QMultiHash m_filePaths; + QHash m_filePathComponentsMap; }; void UpdateIncludeDependenciesVisitor::setModelController(qmt::ModelController *modelController) @@ -322,10 +323,16 @@ void UpdateIncludeDependenciesVisitor::collectElementPaths(const ProjectExplorer qmt::MComponent *UpdateIncludeDependenciesVisitor::findComponentFromFilePath(const QString &filePath) { + const auto it = m_filePathComponentsMap.find(filePath); + if (it != m_filePathComponentsMap.cend()) + return it.value(); + FindComponentFromFilePath visitor; visitor.setFilePath(filePath); m_modelController->rootPackage()->accept(&visitor); - return visitor.component(); + qmt::MComponent *component = visitor.component(); + m_filePathComponentsMap.insert(filePath, component); + return component; } bool UpdateIncludeDependenciesVisitor::haveDependency(const qmt::MObject *source,