forked from qt-creator/qt-creator
Speed up closing all files in a project
Utilize the existing lookup function that does a binary search on the
sorted list of files.
This amends 03f76770e1
.
Change-Id: Idea3e64a9764a9056511353b2df6a375ebcbbcbe
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
@@ -1856,18 +1856,15 @@ void ProjectExplorerPluginPrivate::setStartupProject(Project *project)
|
||||
bool ProjectExplorerPluginPrivate::closeAllFilesInProject(const Project *project)
|
||||
{
|
||||
QTC_ASSERT(project, return false);
|
||||
const Utils::FileNameList filesInProject = project->files(Project::AllFiles);
|
||||
QList<IDocument *> openFiles = DocumentModel::openedDocuments();
|
||||
Utils::erase(openFiles, [filesInProject](const IDocument *doc) {
|
||||
return !filesInProject.contains(doc->filePath());
|
||||
Utils::erase(openFiles, [project](const IDocument *doc) {
|
||||
return !project->isKnownFile(doc->filePath());
|
||||
});
|
||||
for (const Project * const otherProject : SessionManager::projects()) {
|
||||
if (otherProject == project)
|
||||
continue;
|
||||
const Utils::FileNameList filesInOtherProject
|
||||
= otherProject->files(Project::AllFiles);
|
||||
Utils::erase(openFiles, [filesInOtherProject](const IDocument *doc) {
|
||||
return filesInOtherProject.contains(doc->filePath());
|
||||
Utils::erase(openFiles, [otherProject](const IDocument *doc) {
|
||||
return otherProject->isKnownFile(doc->filePath());
|
||||
});
|
||||
}
|
||||
return EditorManager::closeDocuments(openFiles);
|
||||
|
Reference in New Issue
Block a user