Skip to content
Snippets Groups Projects
Commit ca1dd200 authored by Thorbjørn Lindeijer's avatar Thorbjørn Lindeijer
Browse files

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.
parent b170e3ba
No related branches found
No related tags found
No related merge requests found
...@@ -195,10 +195,13 @@ bool GenericProject::addFiles(const QStringList &filePaths) ...@@ -195,10 +195,13 @@ bool GenericProject::addFiles(const QStringList &filePaths)
bool GenericProject::removeFiles(const QStringList &filePaths) bool GenericProject::removeFiles(const QStringList &filePaths)
{ {
// Removing using set allows O(n.log(n)) behavior QStringList newFileList;
QSet<QString> newFileSet = m_files.toSet(); QSet<QString> filesToRemove = filePaths.toSet();
newFileSet.subtract(filePaths.toSet());
QStringList newFileList = newFileSet.toList(); foreach (const QString &file, m_files) {
if (!filesToRemove.contains(file))
newFileList.append(file);
}
return setFiles(newFileList); return setFiles(newFileList);
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment