forked from qt-creator/qt-creator
Made sure the order of the file list is maintained when removing files
Converting to a QSet and back randomizes the order of the files. Just doing a linear scan and a QSet for speading up the contains() check should be enough and maintains the order.
This commit is contained in:
@@ -195,10 +195,13 @@ bool GenericProject::addFiles(const QStringList &filePaths)
|
||||
|
||||
bool GenericProject::removeFiles(const QStringList &filePaths)
|
||||
{
|
||||
// Removing using set allows O(n.log(n)) behavior
|
||||
QSet<QString> newFileSet = m_files.toSet();
|
||||
newFileSet.subtract(filePaths.toSet());
|
||||
QStringList newFileList = newFileSet.toList();
|
||||
QStringList newFileList;
|
||||
QSet<QString> filesToRemove = filePaths.toSet();
|
||||
|
||||
foreach (const QString &file, m_files) {
|
||||
if (!filesToRemove.contains(file))
|
||||
newFileList.append(file);
|
||||
}
|
||||
|
||||
return setFiles(newFileList);
|
||||
}
|
||||
|
Reference in New Issue
Block a user