Skip to content

Commit 4cf93c5

Browse files
committed
optimize for loops in ModDownloadManager::checkAutoConfirm
1 parent 130dd13 commit 4cf93c5

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

loader/src/server/DownloadManager.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -382,13 +382,13 @@ bool ModDownloadManager::checkAutoConfirm() {
382382
for (auto& [_, download] : m_impl->m_downloads) {
383383
auto status = download.getStatus();
384384
if (auto confirm = std::get_if<server::DownloadStatusConfirm>(&status)) {
385-
for (auto inc : confirm->version.metadata.getIncompatibilities()) {
385+
for (auto& inc : confirm->version.metadata.getIncompatibilities()) {
386386
// If some mod has an incompatability that is installed,
387387
// we need to ask for confirmation
388388
if (inc.mod && (!download.getVersion().has_value() || inc.version.compare(download.getVersion().value()))) {
389389
return false;
390390
}
391-
for (auto download : ModDownloadManager::get()->getDownloads()) {
391+
for (auto& download : ModDownloadManager::get()->getDownloads()) {
392392
if (download.isDone() && inc.id == download.getID() && (!download.getVersion().has_value() || inc.version.compare(download.getVersion().value()))) {
393393
return false;
394394
}
@@ -397,7 +397,7 @@ bool ModDownloadManager::checkAutoConfirm() {
397397
// If some installed mod is incompatible with this one,
398398
// we need to ask for confirmation
399399
for (auto mod : Loader::get()->getAllMods()) {
400-
for (auto inc : mod->getMetadata().getIncompatibilities()) {
400+
for (auto& inc : mod->getMetadata().getIncompatibilities()) {
401401
if (inc.id == download.getID() && (!download.getVersion().has_value() || inc.version.compare(download.getVersion().value()))) {
402402
return false;
403403
}
@@ -406,10 +406,10 @@ bool ModDownloadManager::checkAutoConfirm() {
406406

407407
// If some newly downloaded mods are incompatible with this one,
408408
// we need to ask for confirmation
409-
for (auto download : ModDownloadManager::get()->getDownloads()) {
409+
for (auto& download : ModDownloadManager::get()->getDownloads()) {
410410
auto status = download.getStatus();
411411
if (auto done = std::get_if<DownloadStatusDone>(&status)) {
412-
for (auto inc : done->version.metadata.getIncompatibilities()) {
412+
for (auto& inc : done->version.metadata.getIncompatibilities()) {
413413
if (inc.id == download.getID() && inc.version.compare(done->version.metadata.getVersion())) {
414414
return false;
415415
}

0 commit comments

Comments
 (0)