ProjectExplorer: Speed up FolderNode::addNestedNodes()

... by aggregating the look-up of parent folder nodes.
Also make use of this function in the GenericProjectManager.
As a test case, I added my whole ~/dev directory with ca 600,000 source
files to a generic project. With this patch, the time spent on adding
the new nodes to the tree went down from 15 seconds to two seconds.

Task-number: QTCREATORBUG-20652
Change-Id: If006bce55924feacc071c38ec7a0292d29c51be1
Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
Christian Kandeler
2019-11-14 10:52:37 +01:00
parent b1ea9bad7f
commit 18ecbb9b14
2 changed files with 25 additions and 3 deletions

View File

@@ -465,12 +465,14 @@ void GenericBuildSystem::refresh(RefreshOptions options)
// find the common base directory of all source files
FilePath baseDir = findCommonSourceRoot();
std::vector<std::unique_ptr<FileNode>> fileNodes;
for (const QString &f : qAsConst(m_files)) {
FileType fileType = FileType::Source; // ### FIXME
if (f.endsWith(".qrc"))
fileType = FileType::Resource;
newRoot->addNestedNode(std::make_unique<FileNode>(FilePath::fromString(f), fileType), baseDir);
fileNodes.emplace_back(std::make_unique<FileNode>(FilePath::fromString(f), fileType));
}
newRoot->addNestedNodes(std::move(fileNodes), baseDir);
newRoot->addNestedNode(std::make_unique<FileNode>(FilePath::fromString(m_filesFileName),
FileType::Project));