Commit 30064954 authored by dt's avatar dt
Browse files

Fixes: Make opening complex projects 6 times faster.

Details:  Optimize addFileNodes and addFolderNodes. Probably has no
effect for qt4projectmanager.
parent e8161ebd
......@@ -112,6 +112,7 @@ void CMakeProject::parseCMakeLists()
QList<ProjectExplorer::FileNode *> fileList = cbpparser.fileList();
// Manually add the CMakeLists.txt file
fileList.append(new ProjectExplorer::FileNode(sourceDirectory + "/CMakeLists.txt", ProjectExplorer::ProjectFileType, false));
buildTree(m_rootNode, fileList);
foreach (ProjectExplorer::FileNode *fn, fileList)
m_files.append(fn->path());
......@@ -309,6 +310,7 @@ MakeStep *CMakeProject::makeStep() const
return 0;
}
void CMakeProject::restoreSettingsImpl(ProjectExplorer::PersistentSettingsReader &reader)
{
Project::restoreSettingsImpl(reader);
......@@ -341,7 +343,6 @@ void CMakeProject::restoreSettingsImpl(ProjectExplorer::PersistentSettingsReader
}
parseCMakeLists(); // Gets the directory from the active buildconfiguration
if (!hasUserFile) {
......
......@@ -386,14 +386,30 @@ void ProjectNode::addFolderNodes(const QList<FolderNode*> &subFolders, FolderNod
qDebug("Project node has already a parent folder"));
folder->setParentFolderNode(parentFolder);
folder->setProjectNode(this);
// Find the correct place to insert
if (parentFolder->m_subFolderNodes.count() == 0 || sortNodesByPath(parentFolder->m_subFolderNodes.last(), folder)) {
// empty list or greater then last node
parentFolder->m_subFolderNodes.append(folder);
} else {
// Binary Search for insertion point
int l = 0;
int r = parentFolder->m_subFolderNodes.count();
while (l != r) {
int i = (l + r) / 2;
if (sortNodesByPath(folder, parentFolder->m_subFolderNodes.at(i))) {
r = i;
} else {
l = i + 1;
}
}
parentFolder->m_subFolderNodes.insert(l, folder);
}
// project nodes have to be added via addProjectNodes
QTC_ASSERT(folder->nodeType() != ProjectNodeType,
qDebug("project nodes have to be added via addProjectNodes"));
}
qSort(parentFolder->m_subFolderNodes.begin(), parentFolder->m_subFolderNodes.end(),
sortNodesByPath);
if (emitSignals)
foreach (NodesWatcher *watcher, m_watchers)
......@@ -461,9 +477,25 @@ void ProjectNode::addFileNodes(const QList<FileNode*> &files, FolderNode *folder
file->setParentFolderNode(folder);
file->setProjectNode(this);
// Now find the correct place to insert file
if (folder->m_fileNodes.count() == 0 || sortNodesByPath(folder->m_fileNodes.last(), file)) {
// empty list or greater then last node
folder->m_fileNodes.append(file);
} else {
// Binary Search for insertion point
int l = 0;
int r = folder->m_fileNodes.count();
while (l != r) {
int i = (l + r) / 2;
if (sortNodesByPath(file, folder->m_fileNodes.at(i))) {
r = i;
} else {
l = i + 1;
}
}
folder->m_fileNodes.insert(l, file);
}
}
qSort(folder->m_fileNodes.begin(), folder->m_fileNodes.end(), sortNodesByPath);
if (emitSignals)
foreach (NodesWatcher *watcher, m_watchers)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment