From 17f39bd09dc473cb1bc9c765f763d8f43a591824 Mon Sep 17 00:00:00 2001 From: asapelkin Date: Mon, 7 Oct 2019 00:10:26 +0300 Subject: [PATCH] little loops optimization Signed-off-by: asapelkin --- src/csync/csync_exclude.cpp | 4 ++-- src/gui/socketapi.cpp | 2 +- test/testsyncconflict.cpp | 4 ++-- test/testsyncjournaldb.cpp | 4 ++-- test/testsyncmove.cpp | 4 ++-- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/csync/csync_exclude.cpp b/src/csync/csync_exclude.cpp index 1bb66b15d..2b7e65083 100644 --- a/src/csync/csync_exclude.cpp +++ b/src/csync/csync_exclude.cpp @@ -342,8 +342,8 @@ bool ExcludedFiles::reloadExcludeFiles() _fullRegexDir.clear(); bool success = true; - for (auto basePath : _excludeFiles.keys()) { - for (auto file : _excludeFiles.value(basePath)) { + for (const auto& basePath : _excludeFiles.keys()) { + for (const auto& file : _excludeFiles.value(basePath)) { success = loadExcludeFile(basePath, file); } } diff --git a/src/gui/socketapi.cpp b/src/gui/socketapi.cpp index 1ffc3f21a..a45707180 100644 --- a/src/gui/socketapi.cpp +++ b/src/gui/socketapi.cpp @@ -628,7 +628,7 @@ void SocketApi::command_GET_STRINGS(const QString &argument, SocketListener *lis { "EMAIL_PRIVATE_LINK_MENU_TITLE", tr("Send private link by email...") }, } }; listener->sendMessage(QString("GET_STRINGS:BEGIN")); - for (auto key_value : strings) { + for (const auto& key_value : strings) { if (argument.isEmpty() || argument == QLatin1String(key_value.first)) { listener->sendMessage(QString("STRING:%1:%2").arg(key_value.first, key_value.second)); } diff --git a/test/testsyncconflict.cpp b/test/testsyncconflict.cpp index 8703ccc41..2cd318164 100644 --- a/test/testsyncconflict.cpp +++ b/test/testsyncconflict.cpp @@ -543,7 +543,7 @@ private slots: QVERIFY(conflicts.size() == 2); QVERIFY(conflicts[0].contains("A (conflicted copy")); QVERIFY(conflicts[1].contains("B (conflicted copy")); - for (auto conflict : conflicts) + for (const auto& conflict : conflicts) QDir(fakeFolder.localPath() + conflict).removeRecursively(); QCOMPARE(fakeFolder.currentLocalState(), fakeFolder.currentRemoteState()); @@ -581,7 +581,7 @@ private slots: auto conflicts = findConflicts(fakeFolder.currentLocalState()); QVERIFY(conflicts.size() == 1); QVERIFY(conflicts[0].contains("A (conflicted copy")); - for (auto conflict : conflicts) + for (const auto& conflict : conflicts) QDir(fakeFolder.localPath() + conflict).removeRecursively(); QVERIFY(fakeFolder.syncEngine().isAnotherSyncNeeded() == ImmediateFollowUp); diff --git a/test/testsyncjournaldb.cpp b/test/testsyncjournaldb.cpp index f01a69882..792ab8771 100644 --- a/test/testsyncjournaldb.cpp +++ b/test/testsyncjournaldb.cpp @@ -289,12 +289,12 @@ private slots: << "foo bla bar/file" << "fo_" << "fo_/file"; - for (auto elem : elements) + for (const auto& elem : elements) makeEntry(elem); auto checkElements = [&]() { bool ok = true; - for (auto elem : elements) { + for (const auto& elem : elements) { SyncJournalFileRecord record; _db.getFileRecord(elem, &record); if (!record.isValid()) { diff --git a/test/testsyncmove.cpp b/test/testsyncmove.cpp index 5ca6ad293..33aa7414f 100644 --- a/test/testsyncmove.cpp +++ b/test/testsyncmove.cpp @@ -523,13 +523,13 @@ private slots: auto currentLocal = fakeFolder.currentLocalState(); auto conflicts = findConflicts(currentLocal.children["A4"]); QCOMPARE(conflicts.size(), 1); - for (auto c : conflicts) { + for (const auto& c : conflicts) { QCOMPARE(currentLocal.find(c)->contentChar, 'L'); local.remove(c); } conflicts = findConflicts(currentLocal.children["B4"]); QCOMPARE(conflicts.size(), 1); - for (auto c : conflicts) { + for (const auto& c : conflicts) { QCOMPARE(currentLocal.find(c)->contentChar, 'L'); local.remove(c); }