| 334 | } |
| 335 | |
| 336 | void ProjectFileDataProvider::reset() |
| 337 | { |
| 338 | updateItems([this](QVector<ProjectFile>& closedFiles) { |
| 339 | const auto open = openFiles<IndexedStringView>(); |
| 340 | // Don't "optimize" by assigning m_projectFiles to closedFiles and |
| 341 | // returning early if there are no open files. Such an optimization may |
| 342 | // speed up this call to reset() sometimes - if the destruction of the |
| 343 | // previous data of closedFiles doesn't take long for some reason. But |
| 344 | // this "optimization" will discard the current elements and capacity of |
| 345 | // closedFiles, eventually will trigger an extra allocation and |
| 346 | // construction of many ProjectFile objects: when a project is opened or |
| 347 | // closed, when a file is added to/removed from a project, or when a |
| 348 | // file is opened and reset() is called again. See also the |
| 349 | // documentation of PathFilter::updateItems(). |
| 350 | |
| 351 | closedFiles.resize(m_projectFiles.size()); |
| 352 | const auto logicalEnd = std::remove_copy_if( |
| 353 | m_projectFiles.cbegin(), m_projectFiles.cend(), |
| 354 | closedFiles.begin(), [&open](const ProjectFile& f) { |
| 355 | return open.contains(f.indexedPath); |
| 356 | }); |
| 357 | closedFiles.erase(logicalEnd, closedFiles.end()); |
| 358 | }); |
| 359 | } |
| 360 | |
| 361 | QSet<IndexedString> ProjectFileDataProvider::files() const |
| 362 | { |