Simplified ranges::find_if with ranges::any_of and ranges::none_of.

This commit is contained in:
23rd 2020-05-18 22:33:14 +03:00 committed by John Preston
parent 5f238a71f9
commit e318a7d65f
33 changed files with 71 additions and 105 deletions

View file

@ -1811,9 +1811,7 @@ void Updates::feedUpdate(const MTPUpdate &update) {
return !session().data().folderLoaded(data.vfolder_id().v); return !session().data().folderLoaded(data.vfolder_id().v);
}); });
}; };
const auto allLoaded = ranges::find_if(order, notLoaded) if (!ranges::none_of(order, notLoaded)) {
== order.end();
if (!allLoaded) {
return false; return false;
} }
session().data().applyPinnedChats(folder, order); session().data().applyPinnedChats(folder, order);

View file

@ -3578,8 +3578,8 @@ void ApiWrap::addChatParticipants(
}).afterDelay(crl::time(5)).send(); }).afterDelay(crl::time(5)).send();
} }
} else if (const auto channel = peer->asChannel()) { } else if (const auto channel = peer->asChannel()) {
const auto bot = ranges::find_if(users, &UserData::isBot); const auto hasBot = ranges::any_of(users, &UserData::isBot);
if (!peer->isMegagroup() && bot != end(users)) { if (!peer->isMegagroup() && hasBot) {
ShowAddParticipantsError("USER_BOT", peer, users); ShowAddParticipantsError("USER_BOT", peer, users);
return; return;
} }

View file

@ -172,8 +172,7 @@ void ShowAddParticipantsError(
return; return;
} }
} }
const auto bot = ranges::find_if(users, &UserData::isBot); const auto hasBot = ranges::any_of(users, &UserData::isBot);
const auto hasBot = (bot != end(users));
const auto text = [&] { const auto text = [&] {
if (error == qstr("USER_BOT")) { if (error == qstr("USER_BOT")) {
return tr::lng_cant_invite_bot_to_channel(tr::now); return tr::lng_cant_invite_bot_to_channel(tr::now);

View file

@ -172,26 +172,26 @@ void AutoDownloadBox::setupContent() {
}) | ranges::view::transform([](Pair pair) { }) | ranges::view::transform([](Pair pair) {
return pair.first; return pair.first;
}); });
const auto less = ranges::find_if(*autoPlayValues, [&](Pair pair) { const auto less = ranges::any_of(*autoPlayValues, [&](Pair pair) {
const auto [type, enabled] = pair; const auto [type, enabled] = pair;
const auto value = enabled ? limitByType(type) : 0; const auto value = enabled ? limitByType(type) : 0;
return value < settings->bytesLimit(_source, type); return value < settings->bytesLimit(_source, type);
}) != end(*autoPlayValues); });
const auto allowMoreTypes = base::flat_set<Type>( const auto allowMoreTypes = base::flat_set<Type>(
allowMore.begin(), allowMore.begin(),
allowMore.end()); allowMore.end());
const auto changed = ranges::find_if(values, [&](Pair pair) { const auto changed = ranges::any_of(values, [&](Pair pair) {
const auto [type, enabled] = pair; const auto [type, enabled] = pair;
const auto value = enabled ? limitByType(type) : 0; const auto value = enabled ? limitByType(type) : 0;
return value != settings->bytesLimit(_source, type); return value != settings->bytesLimit(_source, type);
}) != end(values); });
const auto &kHidden = kStreamedTypes; const auto &kHidden = kStreamedTypes;
const auto hiddenChanged = ranges::find_if(kHidden, [&](Type type) { const auto hiddenChanged = ranges::any_of(kHidden, [&](Type type) {
const auto now = settings->bytesLimit(_source, type); const auto now = settings->bytesLimit(_source, type);
return (now > 0) && (now != limitByType(type)); return (now > 0) && (now != limitByType(type));
}) != end(kHidden); });
if (changed) { if (changed) {
for (const auto [type, enabled] : values) { for (const auto [type, enabled] : values) {
@ -216,8 +216,7 @@ void AutoDownloadBox::setupContent() {
if (allowMoreTypes.contains(Type::Photo)) { if (allowMoreTypes.contains(Type::Photo)) {
_session->data().photoLoadSettingsChanged(); _session->data().photoLoadSettingsChanged();
} }
if (ranges::find_if(allowMoreTypes, _1 != Type::Photo) if (ranges::any_of(allowMoreTypes, _1 != Type::Photo)) {
!= allowMoreTypes.end()) {
_session->data().documentLoadSettingsChanged(); _session->data().documentLoadSettingsChanged();
} }
if (less) { if (less) {

View file

@ -271,14 +271,14 @@ bool ServiceCheck::checkRippleStartPosition(QPoint position) const {
if (slug.isEmpty() || slug.size() > kMaxWallPaperSlugLength) { if (slug.isEmpty() || slug.size() > kMaxWallPaperSlugLength) {
return false; return false;
} }
return ranges::find_if(slug, [](QChar ch) { return ranges::none_of(slug, [](QChar ch) {
return (ch != '.') return (ch != '.')
&& (ch != '_') && (ch != '_')
&& (ch != '-') && (ch != '-')
&& (ch < '0' || ch > '9') && (ch < '0' || ch > '9')
&& (ch < 'a' || ch > 'z') && (ch < 'a' || ch > 'z')
&& (ch < 'A' || ch > 'Z'); && (ch < 'A' || ch > 'Z');
}) == slug.end(); });
} }
AdminLog::OwnedItem GenerateTextItem( AdminLog::OwnedItem GenerateTextItem(

View file

@ -678,10 +678,7 @@ auto DeleteMessagesBox::revokeText(not_null<PeerData*> peer) const
const auto cannotRevoke = [&](HistoryItem *item) { const auto cannotRevoke = [&](HistoryItem *item) {
return !item->canDeleteForEveryone(now); return !item->canDeleteForEveryone(now);
}; };
const auto canRevokeAll = ranges::find_if( const auto canRevokeAll = ranges::none_of(items, cannotRevoke);
items,
cannotRevoke
) == end(items);
auto outgoing = items | ranges::view::filter(&HistoryItem::out); auto outgoing = items | ranges::view::filter(&HistoryItem::out);
const auto canRevokeOutgoingCount = canRevokeAll const auto canRevokeOutgoingCount = canRevokeAll
? -1 ? -1

View file

@ -1028,7 +1028,7 @@ void ProxiesBoxController::ShowApplyConfirmation(
: QString()); : QString());
*box = Ui::show(Box<ConfirmBox>(text, tr::lng_sure_enable(tr::now), [=] { *box = Ui::show(Box<ConfirmBox>(text, tr::lng_sure_enable(tr::now), [=] {
auto &proxies = Global::RefProxiesList(); auto &proxies = Global::RefProxiesList();
if (ranges::find(proxies, proxy) == end(proxies)) { if (!ranges::contains(proxies, proxy)) {
proxies.push_back(proxy); proxies.push_back(proxy);
} }
Core::App().setCurrentProxy( Core::App().setCurrentProxy(

View file

@ -724,9 +724,8 @@ void Options::removeDestroyed(not_null<Option*> option) {
void Options::validateState() { void Options::validateState() {
checkLastOption(); checkLastOption();
_hasOptions = (ranges::count_if(_list, &Option::isGood) > 1); _hasOptions = (ranges::count_if(_list, &Option::isGood) > 1);
_isValid = _hasOptions _isValid = _hasOptions && ranges::none_of(_list, &Option::isTooLong);
&& (ranges::find_if(_list, &Option::isTooLong) == end(_list)); _hasCorrect = ranges::any_of(_list, &Option::isCorrect);
_hasCorrect = ranges::find_if(_list, &Option::isCorrect) != end(_list);
const auto lastEmpty = !_list.empty() && _list.back()->isEmpty(); const auto lastEmpty = !_list.empty() && _list.back()->isEmpty();
_usedCount = _list.size() - (lastEmpty ? 1 : 0); _usedCount = _list.size() - (lastEmpty ? 1 : 0);

View file

@ -485,12 +485,12 @@ void Controller::usernameChanged() {
_checkUsernameTimer.cancel(); _checkUsernameTimer.cancel();
return; return;
} }
const auto bad = ranges::find_if(username, [](QChar ch) { const auto bad = ranges::any_of(username, [](QChar ch) {
return (ch < 'A' || ch > 'Z') return (ch < 'A' || ch > 'Z')
&& (ch < 'a' || ch > 'z') && (ch < 'a' || ch > 'z')
&& (ch < '0' || ch > '9') && (ch < '0' || ch > '9')
&& (ch != '_'); && (ch != '_');
}) != username.end(); });
if (bad) { if (bad) {
showUsernameError(tr::lng_create_channel_link_bad_symbols()); showUsernameError(tr::lng_create_channel_link_bad_symbols());
} else if (username.size() < kMinUsernameLength) { } else if (username.size() < kMinUsernameLength) {

View file

@ -62,10 +62,7 @@ enum class ButtonType {
}; };
inline bool CanAddUrls(const QList<QUrl> &urls) { inline bool CanAddUrls(const QList<QUrl> &urls) {
return !urls.isEmpty() && ranges::find_if( return !urls.isEmpty() && ranges::all_of(urls, &QUrl::isLocalFile);
urls,
[](const QUrl &url) { return !url.isLocalFile(); }
) == urls.end();
} }
inline bool IsFirstAlbumItem(const Storage::PreparedList &list) { inline bool IsFirstAlbumItem(const Storage::PreparedList &list) {

View file

@ -205,7 +205,7 @@ void AppendLegacySuggestions(
&& (ch != '-') && (ch != '-')
&& (ch != '+'); && (ch != '+');
}; };
if (ranges::find_if(query, badSuggestionChar) != query.end()) { if (ranges::any_of(query, badSuggestionChar)) {
return; return;
} }

View file

@ -101,8 +101,7 @@ auto SuggestionsWidget::getRowsByQuery() const -> std::vector<Row> {
return false; return false;
} }
// Suggest :D and :-P only as exact matches. // Suggest :D and :-P only as exact matches.
return ranges::find_if(_query, [](QChar ch) { return ch.isLower(); }) return ranges::none_of(_query, [](QChar ch) { return ch.isLower(); });
== _query.end();
}(); }();
const auto exact = !middle || simple; const auto exact = !middle || simple;
const auto list = Core::App().emojiKeywords().query(real, exact); const auto list = Core::App().emojiKeywords().query(real, exact);

View file

@ -119,9 +119,9 @@ void EnsurePath() {
} }
bool IsGoodPartName(const QString &name) { bool IsGoodPartName(const QString &name) {
return ranges::find_if(kDictExtensions, [&](const auto &ext) { return ranges::any_of(kDictExtensions, [&](const auto &ext) {
return name.endsWith(ext); return name.endsWith(ext);
}) != end(kDictExtensions); });
} }
using DictLoaderPtr = std::shared_ptr<base::unique_qptr<DictLoader>>; using DictLoaderPtr = std::shared_ptr<base::unique_qptr<DictLoader>>;
@ -268,11 +268,10 @@ bool DictionaryExists(int langId) {
return true; return true;
} }
const auto folder = DictPathByLangId(langId) + '/'; const auto folder = DictPathByLangId(langId) + '/';
const auto bad = ranges::find_if(kDictExtensions, [&](const auto &ext) { return ranges::none_of(kDictExtensions, [&](const auto &ext) {
const auto name = Spellchecker::LocaleFromLangId(langId).name(); const auto name = Spellchecker::LocaleFromLangId(langId).name();
return !QFile(folder + name + '.' + ext).exists(); return !QFile(folder + name + '.' + ext).exists();
}); });
return (bad == end(kDictExtensions));
} }
bool RemoveDictionary(int langId) { bool RemoveDictionary(int langId) {

View file

@ -145,8 +145,8 @@ void ChatData::refreshBotStatus() {
if (participants.empty()) { if (participants.empty()) {
botStatus = 0; botStatus = 0;
} else { } else {
const auto bot = ranges::find_if(participants, &UserData::isBot); const auto bot = ranges::none_of(participants, &UserData::isBot);
botStatus = (bot == end(participants)) ? -1 : 2; botStatus = bot ? -1 : 2;
} }
} }

View file

@ -1482,7 +1482,7 @@ bool DocumentData::isAudioFile() const {
} }
const auto left = _mimeString.midRef(prefix.size()).toString(); const auto left = _mimeString.midRef(prefix.size()).toString();
const auto types = { qstr("x-wav"), qstr("wav"), qstr("mp4") }; const auto types = { qstr("x-wav"), qstr("wav"), qstr("mp4") };
return ranges::find(types, left) != end(types); return ranges::contains(types, left);
} }
bool DocumentData::isSharedMediaMusic() const { bool DocumentData::isSharedMediaMusic() const {

View file

@ -548,10 +548,9 @@ bool Histories::postponeHistoryRequest(const State &state) const {
} }
bool Histories::postponeEntryRequest(const State &state) const { bool Histories::postponeEntryRequest(const State &state) const {
const auto i = ranges::find_if(state.sent, [](const auto &pair) { return ranges::any_of(state.sent, [](const auto &pair) {
return pair.second.type != RequestType::History; return pair.second.type != RequestType::History;
}); });
return (i != end(state.sent));
} }
void Histories::deleteMessages( void Histories::deleteMessages(

View file

@ -416,7 +416,7 @@ QString PeerData::computeUnavailableReason() const {
auto &&filtered = ranges::view::all( auto &&filtered = ranges::view::all(
list list
) | ranges::view::filter([&](const Data::UnavailableReason &reason) { ) | ranges::view::filter([&](const Data::UnavailableReason &reason) {
return ranges::find(skip, reason.reason) == end(skip); return !ranges::contains(skip, reason.reason);
}); });
const auto first = filtered.begin(); const auto first = filtered.begin();
return (first != filtered.end()) ? first->text : QString(); return (first != filtered.end()) ? first->text : QString();

View file

@ -236,7 +236,7 @@ PollData::Flags PollData::flags() const {
} }
bool PollData::voted() const { bool PollData::voted() const {
return ranges::find(answers, true, &PollAnswer::chosen) != end(answers); return ranges::contains(answers, true, &PollAnswer::chosen);
} }
bool PollData::closed() const { bool PollData::closed() const {

View file

@ -3822,10 +3822,7 @@ void Session::setWallpapers(const QVector<MTPWallPaper> &data, int32 hash) {
_wallpapers.push_back(*parsed); _wallpapers.push_back(*parsed);
} }
} }
const auto defaultFound = ranges::find_if( if (ranges::none_of(_wallpapers, Data::IsDefaultWallPaper)) {
_wallpapers,
Data::IsDefaultWallPaper);
if (defaultFound == end(_wallpapers)) {
_wallpapers.push_back(Data::DefaultWallPaper()); _wallpapers.push_back(Data::DefaultWallPaper());
_wallpapers.back().setLocalImageAsThumbnail(std::make_shared<Image>( _wallpapers.back().setLocalImageAsThumbnail(std::make_shared<Image>(
u":/gui/arg/bg.jpg"_q)); u":/gui/arg/bg.jpg"_q));

View file

@ -51,11 +51,11 @@ std::optional<QColor> MaybeColorFromSerialized(quint32 serialized) {
std::optional<QColor> ColorFromString(const QString &string) { std::optional<QColor> ColorFromString(const QString &string) {
if (string.size() != 6) { if (string.size() != 6) {
return {}; return {};
} else if (ranges::find_if(string, [](QChar ch) { } else if (ranges::any_of(string, [](QChar ch) {
return (ch < 'a' || ch > 'f') return (ch < 'a' || ch > 'f')
&& (ch < 'A' || ch > 'F') && (ch < 'A' || ch > 'F')
&& (ch < '0' || ch > '9'); && (ch < '0' || ch > '9');
}) != string.end()) { })) {
return {}; return {};
} }
const auto component = [](const QString &text, int index) { const auto component = [](const QString &text, int index) {

View file

@ -245,9 +245,9 @@ void AddPostLinkAction(
MessageIdsList ExtractIdsList(const SelectedItems &items) { MessageIdsList ExtractIdsList(const SelectedItems &items) {
return ranges::view::all( return ranges::view::all(
items items
) | ranges::view::transform([](const auto &item) { ) | ranges::view::transform(
return item.msgId; &SelectedItem::msgId
}) | ranges::to_vector; ) | ranges::to_vector;
} }
bool AddForwardSelectedAction( bool AddForwardSelectedAction(
@ -257,9 +257,7 @@ bool AddForwardSelectedAction(
if (!request.overSelection || request.selectedItems.empty()) { if (!request.overSelection || request.selectedItems.empty()) {
return false; return false;
} }
if (ranges::find_if(request.selectedItems, [](const auto &item) { if (!ranges::all_of(request.selectedItems, &SelectedItem::canForward)) {
return !item.canForward;
}) != end(request.selectedItems)) {
return false; return false;
} }
@ -292,9 +290,7 @@ bool AddForwardMessageAction(
const auto asGroup = (request.pointState != PointState::GroupPart); const auto asGroup = (request.pointState != PointState::GroupPart);
if (asGroup) { if (asGroup) {
if (const auto group = owner->groups().find(item)) { if (const auto group = owner->groups().find(item)) {
if (ranges::find_if(group->items, [](auto item) { if (!ranges::all_of(group->items, &HistoryItem::allowsForward)) {
return !item->allowsForward();
}) != end(group->items)) {
return false; return false;
} }
} }
@ -327,9 +323,7 @@ bool AddSendNowSelectedAction(
if (!request.overSelection || request.selectedItems.empty()) { if (!request.overSelection || request.selectedItems.empty()) {
return false; return false;
} }
if (ranges::find_if(request.selectedItems, [](const auto &item) { if (!ranges::all_of(request.selectedItems, &SelectedItem::canSendNow)) {
return !item.canSendNow;
}) != end(request.selectedItems)) {
return false; return false;
} }
@ -340,9 +334,9 @@ bool AddSendNowSelectedAction(
return session->data().message(item.msgId); return session->data().message(item.msgId);
}) | ranges::view::filter([](HistoryItem *item) { }) | ranges::view::filter([](HistoryItem *item) {
return item != nullptr; return item != nullptr;
}) | ranges::view::transform([](not_null<HistoryItem*> item) { }) | ranges::view::transform(
return item->history(); &HistoryItem::history
}); );
if (histories.begin() == histories.end()) { if (histories.begin() == histories.end()) {
return false; return false;
} }
@ -376,9 +370,7 @@ bool AddSendNowMessageAction(
const auto asGroup = (request.pointState != PointState::GroupPart); const auto asGroup = (request.pointState != PointState::GroupPart);
if (asGroup) { if (asGroup) {
if (const auto group = owner->groups().find(item)) { if (const auto group = owner->groups().find(item)) {
if (ranges::find_if(group->items, [](auto item) { if (!ranges::all_of(group->items, &HistoryItem::allowsSendNow)) {
return !item->allowsSendNow();
}) != end(group->items)) {
return false; return false;
} }
} }
@ -464,9 +456,7 @@ bool AddDeleteSelectedAction(
if (!request.overSelection || request.selectedItems.empty()) { if (!request.overSelection || request.selectedItems.empty()) {
return false; return false;
} }
if (ranges::find_if(request.selectedItems, [](const auto &item) { if (!ranges::all_of(request.selectedItems, &SelectedItem::canDelete)) {
return !item.canDelete;
}) != end(request.selectedItems)) {
return false; return false;
} }
@ -499,10 +489,10 @@ bool AddDeleteMessageAction(
const auto asGroup = (request.pointState != PointState::GroupPart); const auto asGroup = (request.pointState != PointState::GroupPart);
if (asGroup) { if (asGroup) {
if (const auto group = owner->groups().find(item)) { if (const auto group = owner->groups().find(item)) {
if (ranges::find_if(group->items, [](auto item) { if (ranges::any_of(group->items, [](auto item) {
const auto id = ItemIdAcrossData(item); const auto id = ItemIdAcrossData(item);
return !IsServerMsgId(id) || !item->canDelete(); return !IsServerMsgId(id) || !item->canDelete();
}) != end(group->items)) { })) {
return false; return false;
} }
} }

View file

@ -480,10 +480,7 @@ void TopBar::createSelectionControls() {
} }
bool TopBar::computeCanDelete() const { bool TopBar::computeCanDelete() const {
return ranges::find_if( return ranges::all_of(_selectedItems.list, &SelectedItem::canDelete);
_selectedItems.list,
[](const SelectedItem &item) { return !item.canDelete; }
) == _selectedItems.list.end();
} }
Ui::StringWithNumbers TopBar::generateSelectedText() const { Ui::StringWithNumbers TopBar::generateSelectedText() const {

View file

@ -1280,14 +1280,14 @@ void ListWidget::showContextMenu(
} }
auto canDeleteAll = [&] { auto canDeleteAll = [&] {
return ranges::find_if(_selected, [](auto &&item) { return ranges::none_of(_selected, [](auto &&item) {
return !item.second.canDelete; return !item.second.canDelete;
}) == _selected.end(); });
}; };
auto canForwardAll = [&] { auto canForwardAll = [&] {
return ranges::find_if(_selected, [](auto &&item) { return ranges::none_of(_selected, [](auto &&item) {
return !item.second.canForward; return !item.second.canForward;
}) == _selected.end(); });
}; };
auto link = ClickHandler::getActive(); auto link = ClickHandler::getActive();

View file

@ -514,10 +514,9 @@ bool Reader::Slices::checkFullInCache() const {
if (isFullInHeader()) { if (isFullInHeader()) {
return (_header.flags & Flag::FullInCache); return (_header.flags & Flag::FullInCache);
} }
const auto i = ranges::find_if(_data, [](const Slice &slice) { return ranges::none_of(_data, [](const Slice &slice) {
return !(slice.flags & Flag::FullInCache); return !(slice.flags & Flag::FullInCache);
}); });
return (i == end(_data));
} }
void Reader::Slices::processPart( void Reader::Slices::processPart(

View file

@ -742,7 +742,7 @@ void DcOptions::FilterIfHasWithFlag(Variants &variants, Flag flag) {
return (endpoint.flags & flag) != 0; return (endpoint.flags & flag) != 0;
}; };
const auto has = [&](const std::vector<Endpoint> &list) { const auto has = [&](const std::vector<Endpoint> &list) {
return ranges::find_if(list, is) != end(list); return ranges::any_of(list, is);
}; };
for (auto &byAddress : variants.data) { for (auto &byAddress : variants.data) {
for (auto &list : byAddress) { for (auto &list : byAddress) {

View file

@ -502,15 +502,15 @@ bool Value::uploadingScan() const {
}; };
const auto uploadingInList = [&](FileType type) { const auto uploadingInList = [&](FileType type) {
const auto &list = filesInEdit(type); const auto &list = filesInEdit(type);
return ranges::find_if(list, uploading) != end(list); return ranges::any_of(list, uploading);
}; };
if (uploadingInList(FileType::Scan) if (uploadingInList(FileType::Scan)
|| uploadingInList(FileType::Translation)) { || uploadingInList(FileType::Translation)) {
return true; return true;
} }
if (ranges::find_if(specialScansInEdit, [&](const auto &pair) { if (ranges::any_of(specialScansInEdit, [&](const auto &pair) {
return uploading(pair.second); return uploading(pair.second);
}) != end(specialScansInEdit)) { })) {
return true; return true;
} }
return false; return false;

View file

@ -73,15 +73,14 @@ bool InlineDetails(
if (count != 1) { if (count != 1) {
return false; return false;
} }
const auto has = ranges::find_if( return ranges::any_of(
request, request,
[&](const std::vector<Value::Type> &types) { [&](const std::vector<Value::Type> &types) {
Expects(!types.empty()); Expects(!types.empty());
return (types[0] == details); return (types[0] == details);
} }
) != end(request); );
return has;
} }
bool InlineDetails(const Form::Request &request, Value::Type details) { bool InlineDetails(const Form::Request &request, Value::Type details) {

View file

@ -186,16 +186,15 @@ bool EditScans::List::uploadMoreRequired() const {
if (!upload) { if (!upload) {
return false; return false;
} }
const auto exists = ranges::find_if( const auto exists = ranges::any_of(
files, files,
[](const ScanInfo &file) { return !file.deleted; }) != end(files); [](const ScanInfo &file) { return !file.deleted; });
if (!exists) { if (!exists) {
return true; return true;
} }
const auto errorExists = ranges::find_if( const auto errorExists = ranges::any_of(
files, files,
[](const ScanInfo &file) { return !file.error.isEmpty(); } [](const ScanInfo &file) { return !file.error.isEmpty(); });
) != end(files);
return (errorExists || uploadMoreError) && !uploadedSomeMore(); return (errorExists || uploadMoreError) && !uploadedSomeMore();
} }

View file

@ -879,9 +879,9 @@ bool OpenSystemSettings(SystemSettingsType type) {
add("pavucontrol-qt"); add("pavucontrol-qt");
add("pavucontrol"); add("pavucontrol");
add("alsamixergui"); add("alsamixergui");
return ranges::find_if(options, [](const QString &command) { return ranges::any_of(options, [](const QString &command) {
return QProcess::startDetached(command); return QProcess::startDetached(command);
}) != end(options); });
} }
return true; return true;
} }

View file

@ -805,7 +805,7 @@ void AppendEmojiPacks(
}; };
const auto checkState = [&](const auto &states) { const auto checkState = [&](const auto &states) {
return ranges::find(states, gesture.state) != end(states); return ranges::contains(states, gesture.state);
}; };
if (checkState(kGestureStateProcessed)) { if (checkState(kGestureStateProcessed)) {

View file

@ -240,9 +240,9 @@ void CodesFeedString(SessionController *window, const QString &text) {
} }
if (found) break; if (found) break;
found = ranges::find_if(codes, [&](const auto &pair) { found = ranges::any_of(codes, [&](const auto &pair) {
return pair.first.startsWith(piece); return pair.first.startsWith(piece);
}) != end(codes); });
if (found) break; if (found) break;
++from; ++from;

View file

@ -268,11 +268,11 @@ void DownloadManagerMtproto::requestSucceeded(
).arg(data.maxWaitedAmount)); ).arg(data.maxWaitedAmount));
} }
data.successes = std::min(data.successes + 1, kMaxTrackedSuccesses); data.successes = std::min(data.successes + 1, kMaxTrackedSuccesses);
const auto notEnough = ranges::find_if( const auto notEnough = ranges::any_of(
dc.sessions, dc.sessions,
_1 < (dc.sessionRemoveTimes + 1) * kRetryAddSessionSuccesses, _1 < (dc.sessionRemoveTimes + 1) * kRetryAddSessionSuccesses,
&DcSessionBalanceData::successes); &DcSessionBalanceData::successes);
if (notEnough != end(dc.sessions)) { if (notEnough) {
return; return;
} }
for (auto &session : dc.sessions) { for (auto &session : dc.sessions) {

View file

@ -400,13 +400,12 @@ bool CopyColorsToPalette(
if (slug.size() < kMinSlugSize || slug.size() > kMaxSlugSize) { if (slug.size() < kMinSlugSize || slug.size() > kMaxSlugSize) {
return false; return false;
} }
const auto i = ranges::find_if(slug, [](QChar ch) { return ranges::none_of(slug, [](QChar ch) {
return (ch < 'A' || ch > 'Z') return (ch < 'A' || ch > 'Z')
&& (ch < 'a' || ch > 'z') && (ch < 'a' || ch > 'z')
&& (ch < '0' || ch > '9') && (ch < '0' || ch > '9')
&& (ch != '_'); && (ch != '_');
}); });
return (i == slug.end());
} }
SendMediaReady PrepareThemeMedia( SendMediaReady PrepareThemeMedia(