From caf694954839415f426b09c7f20733f570ee583c Mon Sep 17 00:00:00 2001 From: Christian Kandeler Date: Fri, 15 Feb 2019 15:02:29 +0100 Subject: [PATCH] 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 --- src/plugins/projectexplorer/projectexplorer.cpp | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/plugins/projectexplorer/projectexplorer.cpp b/src/plugins/projectexplorer/projectexplorer.cpp index 7caef6e4b37..d7c2250c537 100644 --- a/src/plugins/projectexplorer/projectexplorer.cpp +++ b/src/plugins/projectexplorer/projectexplorer.cpp @@ -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 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);