Replace find_if with none_of where appropriate.
authorHarald Eilertsen <haraldei@anduin.net>
Tue, 29 Sep 2020 17:23:06 +0000 (19:23 +0200)
committerHarald Eilertsen <haraldei@anduin.net>
Tue, 29 Sep 2020 17:32:39 +0000 (19:32 +0200)
We're not interested in any found element in these cases, just to check
that none of the elements matches.

Signed-off-by: Harald Eilertsen <haraldei@anduin.net>
src/gui/accountmanager.cpp
src/gui/folder.cpp
src/gui/folderman.cpp

index 3656a49a0e04ca137bdff508e34cff80890d47ee..fa9da6237408310d2fa794ac5a61811519a4d60e 100644 (file)
@@ -372,10 +372,9 @@ void AccountManager::shutdown()
 
 bool AccountManager::isAccountIdAvailable(const QString &id) const
 {
-    const auto it = std::find_if(_accounts.cbegin(), _accounts.cend(), [id](const auto &acc) {
+    return std::none_of(_accounts.cbegin(), _accounts.cend(), [id](const auto &acc) {
         return acc->account()->id() == id;
     });
-    return it == _accounts.cend();
 }
 
 QString AccountManager::generateFreeAccountId() const
index b4bfab3e6e1984182f01e07252a32ba85d37123a..b047d7f85b5dbf4c136c70d0f7365b140f9b009d 100644 (file)
@@ -529,11 +529,10 @@ void Folder::saveToSettings() const
     // where two folders for different accounts point at the same
     // local folders.
     const auto folderMap = FolderMan::instance()->map();
-    const auto it = std::find_if(folderMap.cbegin(), folderMap.cend(), [this](const auto *other) {
+    const auto oneAccountOnly = std::none_of(folderMap.cbegin(), folderMap.cend(), [this](const auto *other) {
         return other != this && other->cleanPath() == this->cleanPath();
     });
 
-    bool oneAccountOnly = it == folderMap.cend();
     bool compatible = _saveBackwardsCompatible || oneAccountOnly;
 
     if (compatible) {
index 92a842488326977d3afa394d348bb65f96b44801..422657f8297d6608d2856f9a88faa899c4674681 100755 (executable)
@@ -914,11 +914,10 @@ Folder *FolderMan::addFolder(AccountState *accountState, const FolderDefinition
     // Migration: The first account that's configured for a local folder shall
     // be saved in a backwards-compatible way.
     const auto folderList = FolderMan::instance()->map();
-    const auto it = std::find_if(folderList.cbegin(), folderList.cend(), [this, folder](const auto *other) {
+    const auto oneAccountOnly = std::none_of(folderList.cbegin(), folderList.cend(), [this, folder](const auto *other) {
         return other != folder && other->cleanPath() == folder->cleanPath();
     });
 
-    bool oneAccountOnly = it == folderList.cend();
     folder->setSaveBackwardsCompatible(oneAccountOnly);
 
     if (folder) {