From: Harald Eilertsen Date: Tue, 29 Sep 2020 17:23:06 +0000 (+0200) Subject: Replace find_if with none_of where appropriate. X-Git-Tag: archive/raspbian/3.16.7-1_deb13u1+rpi1~1^2~12^2~22^2~137^2 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=7721da25e553d6a65600d0fa6fab1bee32d7d308;p=nextcloud-desktop.git Replace find_if with none_of where appropriate. 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 --- diff --git a/src/gui/accountmanager.cpp b/src/gui/accountmanager.cpp index 3656a49a0..fa9da6237 100644 --- a/src/gui/accountmanager.cpp +++ b/src/gui/accountmanager.cpp @@ -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 diff --git a/src/gui/folder.cpp b/src/gui/folder.cpp index b4bfab3e6..b047d7f85 100644 --- a/src/gui/folder.cpp +++ b/src/gui/folder.cpp @@ -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) { diff --git a/src/gui/folderman.cpp b/src/gui/folderman.cpp index 92a842488..422657f82 100755 --- a/src/gui/folderman.cpp +++ b/src/gui/folderman.cpp @@ -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) {