Quick Open: don't copy QSet before subtracting openFiles()
When there are multiple open projects and at least one open document, in the `Algorithm::unite(std::move(sets)) - openFiles()` expression Algorithm::unite() returns a temporary set union, QSet::operator-() copies this temporary QSet and unites the copy with the result of openFiles(). Using QSet::subtract() or equivalently QSet::operator-=() eliminates this unnecessary deep copying. Functions and/or Classes have to be selected as Items in Quick Open popup to ensure that ProjectFileDataProvider::files() is called each time the Quick Open popup is shown. The average time spent in the `m_files = m_quickopen->fileSet();` statement at the top of ProjectItemDataProvider::reset()'s definition before and at this commit: Open projects File count Before (ms) At (ms) * kdevelop and WebKit 386574+7 153 81 * kdevelop, WebKit, 11 408954+25 157 89 much smaller projects The format of the *File count* column in the table above is: <QSet size returned by ProjectFileDataProvider::files()>+<open document count>. This optimization does not affect performance when a single project is open, because in this case the QSet returned by Algorithm::unite() is not temporary, but a shallow copy of the project's fileSet, so deep copying before subtracting openFiles() is unavoidable. The performance also remains the same when there are no open documents, because QSet::operator-() does not detach when the subtrahend QSet is empty. Average BenchQuickOpen::benchProjectFileFilter_files results before and at this commit: Data row Before (ms) At (ms) 8 projects+open 440 241 The other benchmark's data rows are unaffected by the optimization, because they do not open documents.
!188 with optimize-quickopen-files in 48 minutes and 31 seconds (queued for 32 minutes and 17 seconds)1 job for
||linux kf5-qt5 qt5.12||
|linux kf5-qt5 qt5.12||Build|