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 <haraldei@anduin.net>
This commit is contained in:
Harald Eilertsen 2020-09-29 19:23:06 +02:00
parent 061ef027ff
commit 7721da25e5
3 changed files with 3 additions and 6 deletions

View 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

View 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) {

View file

@ -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) {