summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAL <26797547+Al12rs@users.noreply.github.com>2020-11-02 23:20:43 +0100
committerAL <26797547+Al12rs@users.noreply.github.com>2020-11-02 23:20:43 +0100
commitc5e3fb423fd144faa2db8f2bb156adba6c003d39 (patch)
tree823e38d3f0af39be96a4a2b2d8264b7c851ed08b
parent4814ba626e80f5137076556b687e59e6bbd8be34 (diff)
Change some for loops to use refs, prefer range loop where possible.
-rw-r--r--src/modinfowithconflictinfo.cpp4
-rw-r--r--src/organizercore.cpp10
-rw-r--r--src/processrunner.cpp2
-rw-r--r--src/shared/fileentry.cpp2
-rw-r--r--src/shared/fileregister.cpp4
-rw-r--r--src/syncoverwritedialog.cpp4
6 files changed, 13 insertions, 13 deletions
diff --git a/src/modinfowithconflictinfo.cpp b/src/modinfowithconflictinfo.cpp
index 3db41147..24c154e6 100644
--- a/src/modinfowithconflictinfo.cpp
+++ b/src/modinfowithconflictinfo.cpp
@@ -154,7 +154,7 @@ void ModInfoWithConflictInfo::doConflictCheck() const
if (file->getOrigin() == origin.getID())
archiveData = file->getArchive();
else {
- for (auto alt : alternatives) {
+ for (const auto& alt : alternatives) {
if (alt.originID() == origin.getID()) {
archiveData = alt.archive();
break;
@@ -180,7 +180,7 @@ void ModInfoWithConflictInfo::doConflictCheck() const
}
// Sort out the alternatives
- for (auto altInfo : alternatives) {
+ for (const auto& altInfo : alternatives) {
if ((altInfo.originID() != dataID) && (altInfo.originID() != origin.getID())) {
FilesOrigin &altOrigin = (*m_DirectoryStructure)->getOriginByID(altInfo.originID());
QString altOriginName = ToQString(altOrigin.getName());
diff --git a/src/organizercore.cpp b/src/organizercore.cpp
index 608e13b6..1c35720b 100644
--- a/src/organizercore.cpp
+++ b/src/organizercore.cpp
@@ -919,7 +919,7 @@ QStringList OrganizerCore::getFileOrigins(const QString &fileName) const
if (file.get() != nullptr) {
result.append(ToQString(
m_DirectoryStructure->getOriginByID(file->getOrigin()).getName()));
- foreach (auto i, file->getAlternatives()) {
+ foreach (const auto& i, file->getAlternatives()) {
result.append(
ToQString(m_DirectoryStructure->getOriginByID(i.originID()).getName()));
}
@@ -938,7 +938,7 @@ QList<MOBase::IOrganizer::FileInfo> OrganizerCore::findFileInfos(
dir = dir->findSubDirectoryRecursive(ToWString(path));
if (dir != nullptr) {
std::vector<FileEntryPtr> files = dir->getFiles();
- foreach (FileEntryPtr file, files) {
+ for (FileEntryPtr file : files) {
IOrganizer::FileInfo info;
info.filePath = ToQString(file->getFullPath());
bool fromArchive = false;
@@ -946,7 +946,7 @@ QList<MOBase::IOrganizer::FileInfo> OrganizerCore::findFileInfos(
m_DirectoryStructure->getOriginByID(file->getOrigin(fromArchive))
.getName()));
info.archive = fromArchive ? ToQString(file->getArchive().name()) : "";
- foreach (auto idx, file->getAlternatives()) {
+ for (const auto& idx : file->getAlternatives()) {
info.origins.append(
ToQString(m_DirectoryStructure->getOriginByID(idx.originID()).getName()));
}
@@ -1048,7 +1048,7 @@ bool OrganizerCore::previewFileWithAlternatives(
if (selectedOrigin == -1) {
// don't bother with the vector of origins, just add them as they come
addFunc(file->getOrigin());
- for (auto alt : file->getAlternatives()) {
+ for (const auto& alt : file->getAlternatives()) {
addFunc(alt.originID());
}
} else {
@@ -1058,7 +1058,7 @@ bool OrganizerCore::previewFileWithAlternatives(
origins.push_back(file->getOrigin());
// add other origins, push to front if it's the selected one
- for (auto alt : file->getAlternatives()) {
+ for (const auto& alt : file->getAlternatives()) {
if (alt.originID() == selectedOrigin) {
origins.insert(origins.begin(), alt.originID());
} else {
diff --git a/src/processrunner.cpp b/src/processrunner.cpp
index 97b5c580..a0e74f47 100644
--- a/src/processrunner.cpp
+++ b/src/processrunner.cpp
@@ -153,7 +153,7 @@ InterestingProcess findInterestingProcessInTrees(const env::Process& root)
}
auto isHidden = [&](auto&& p) {
- for (auto h : hiddenList) {
+ for (auto& h : hiddenList) {
if (p.name().contains(h, Qt::CaseInsensitive)) {
return true;
}
diff --git a/src/shared/fileentry.cpp b/src/shared/fileentry.cpp
index 559eae64..5be9a9dc 100644
--- a/src/shared/fileentry.cpp
+++ b/src/shared/fileentry.cpp
@@ -192,7 +192,7 @@ bool FileEntry::isFromArchive(std::wstring archiveName) const
return true;
}
- for (auto alternative : m_Alternatives) {
+ for (const auto& alternative : m_Alternatives) {
if (alternative.archive().name().compare(archiveName) == 0) {
return true;
}
diff --git a/src/shared/fileregister.cpp b/src/shared/fileregister.cpp
index f9d57734..98e49452 100644
--- a/src/shared/fileregister.cpp
+++ b/src/shared/fileregister.cpp
@@ -171,8 +171,8 @@ void FileRegister::unregisterFile(FileEntryPtr file)
m_OriginConnection->getByID(originID).removeFile(file->getIndex());
const auto& alternatives = file->getAlternatives();
- for (auto iter = alternatives.begin(); iter != alternatives.end(); ++iter) {
- m_OriginConnection->getByID(iter->originID()).removeFile(file->getIndex());
+ for (const auto& alt : alternatives) {
+ m_OriginConnection->getByID(alt.originID()).removeFile(file->getIndex());
}
// unregister from directory
diff --git a/src/syncoverwritedialog.cpp b/src/syncoverwritedialog.cpp
index e777fb8a..41c2b202 100644
--- a/src/syncoverwritedialog.cpp
+++ b/src/syncoverwritedialog.cpp
@@ -103,8 +103,8 @@ void SyncOverwriteDialog::readTree(const QString &path, DirectoryEntry *director
int origin = entry->getOrigin(ignore);
addToComboBox(combo, ToQString(m_DirectoryStructure->getOriginByID(origin).getName()), origin);
const auto &alternatives = entry->getAlternatives();
- for (auto iter = alternatives.begin(); iter != alternatives.end(); ++iter) {
- addToComboBox(combo, ToQString(m_DirectoryStructure->getOriginByID(iter->originID()).getName()), iter->originID());
+ for (const auto& alt : alternatives) {
+ addToComboBox(combo, ToQString(m_DirectoryStructure->getOriginByID(alt.originID()).getName()), alt.originID());
}
combo->setCurrentIndex(combo->count() - 1);
} else {