diff --git a/Telegram/SourceFiles/api/api_user_privacy.cpp b/Telegram/SourceFiles/api/api_user_privacy.cpp index d3b075b07..6baf18129 100644 --- a/Telegram/SourceFiles/api/api_user_privacy.cpp +++ b/Telegram/SourceFiles/api/api_user_privacy.cpp @@ -28,7 +28,7 @@ TLInputRules RulesToTL(const UserPrivacy::Rule &rule) { const auto collectInputUsers = [](const auto &peers) { auto result = QVector(); result.reserve(peers.size()); - for (const auto peer : peers) { + for (const auto &peer : peers) { if (const auto user = peer->asUser()) { result.push_back(user->inputUser); } @@ -38,7 +38,7 @@ TLInputRules RulesToTL(const UserPrivacy::Rule &rule) { const auto collectInputChats = [](const auto &peers) { auto result = QVector(); result.reserve(peers.size()); - for (const auto peer : peers) { + for (const auto &peer : peers) { if (!peer->isUser()) { result.push_back(peerToBareMTPInt(peer->id)); } @@ -112,7 +112,7 @@ UserPrivacy::Rule TLToRules(const TLRules &rules, Data::Session &owner) { }, [&](const MTPDprivacyValueAllowUsers &data) { const auto &users = data.vusers().v; always.reserve(always.size() + users.size()); - for (const auto userId : users) { + for (const auto &userId : users) { const auto user = owner.user(UserId(userId.v)); if (!base::contains(never, user) && !base::contains(always, user)) { @@ -140,7 +140,7 @@ UserPrivacy::Rule TLToRules(const TLRules &rules, Data::Session &owner) { }, [&](const MTPDprivacyValueDisallowUsers &data) { const auto &users = data.vusers().v; never.reserve(never.size() + users.size()); - for (const auto userId : users) { + for (const auto &userId : users) { const auto user = owner.user(UserId(userId.v)); if (!base::contains(always, user) && !base::contains(never, user)) { diff --git a/Telegram/SourceFiles/apiwrap.cpp b/Telegram/SourceFiles/apiwrap.cpp index f170b2c48..da301bdd1 100644 --- a/Telegram/SourceFiles/apiwrap.cpp +++ b/Telegram/SourceFiles/apiwrap.cpp @@ -1295,7 +1295,7 @@ void ApiWrap::markMediaRead( not_null, QVector>(); markedIds.reserve(items.size()); - for (const auto item : items) { + for (const auto &item : items) { if ((!item->isUnreadMedia() || item->out()) && !item->isUnreadMention()) { continue; @@ -2400,7 +2400,7 @@ void ApiWrap::applyAffectedMessages( void ApiWrap::saveCurrentDraftToCloud() { Core::App().saveCurrentDraftsToHistories(); - for (const auto controller : _session->windows()) { + for (const auto &controller : _session->windows()) { if (const auto history = controller->activeChatCurrent().history()) { _session->local().writeDrafts(history); @@ -3415,7 +3415,7 @@ void ApiWrap::addChatParticipants( const std::vector> &users, Fn done) { if (const auto chat = peer->asChat()) { - for (const auto user : users) { + for (const auto &user : users) { request(MTPmessages_AddChatUser( chat->inputChat, user->inputUser, @@ -3450,7 +3450,7 @@ void ApiWrap::addChatParticipants( if (callback) callback(false); }).afterDelay(crl::time(5)).send(); }; - for (const auto user : users) { + for (const auto &user : users) { list.push_back(user->inputUser); if (list.size() == kMaxUsersPerInvite) { send(); diff --git a/Telegram/SourceFiles/boxes/confirm_box.cpp b/Telegram/SourceFiles/boxes/confirm_box.cpp index c72e17e13..97b649820 100644 --- a/Telegram/SourceFiles/boxes/confirm_box.cpp +++ b/Telegram/SourceFiles/boxes/confirm_box.cpp @@ -719,7 +719,7 @@ void DeleteMessagesBox::prepare() { } bool DeleteMessagesBox::hasScheduledMessages() const { - for (const auto fullId : std::as_const(_ids)) { + for (const auto &fullId : _ids) { if (const auto item = _session->data().message(fullId)) { if (item->isScheduled()) { return true; @@ -731,7 +731,7 @@ bool DeleteMessagesBox::hasScheduledMessages() const { PeerData *DeleteMessagesBox::checkFromSinglePeer() const { auto result = (PeerData*)nullptr; - for (const auto fullId : std::as_const(_ids)) { + for (const auto &fullId : _ids) { if (const auto item = _session->data().message(fullId)) { const auto peer = item->history()->peer; if (!result) { @@ -881,7 +881,7 @@ void DeleteMessagesBox::deleteAndClear() { if (justClear) { peer->session().api().clearHistory(peer, revoke); } else { - for (const auto controller : peer->session().windows()) { + for (const auto &controller : peer->session().windows()) { if (controller->activeChatCurrent().peer() == peer) { Ui::showChatsList(&peer->session()); } diff --git a/Telegram/SourceFiles/boxes/confirm_phone_box.cpp b/Telegram/SourceFiles/boxes/confirm_phone_box.cpp index e8b882259..2584c1485 100644 --- a/Telegram/SourceFiles/boxes/confirm_phone_box.cpp +++ b/Telegram/SourceFiles/boxes/confirm_phone_box.cpp @@ -106,7 +106,7 @@ void SentCodeField::fix() { auto newPos = -1; auto oldLen = now.size(); auto digitCount = 0; - for (const auto ch : now) { + for (const auto &ch : now) { if (ch.isDigit()) { ++digitCount; } @@ -120,7 +120,7 @@ void SentCodeField::fix() { newText.reserve(oldLen); int i = 0; - for (const auto ch : now) { + for (const auto &ch : now) { if (i++ == oldPos) { newPos = newText.length(); } diff --git a/Telegram/SourceFiles/boxes/filters/edit_filter_box.cpp b/Telegram/SourceFiles/boxes/filters/edit_filter_box.cpp index ec546d184..ce4b4b00d 100644 --- a/Telegram/SourceFiles/boxes/filters/edit_filter_box.cpp +++ b/Telegram/SourceFiles/boxes/filters/edit_filter_box.cpp @@ -186,7 +186,7 @@ void FilterChatsPreview::updateData( makeButton([=] { removeFlag(flag); }) }); } } - for (const auto history : peers) { + for (const auto &history : peers) { _removePeer.push_back(PeerButton{ .history = history, .button = makeButton([=] { removePeer(history); }) diff --git a/Telegram/SourceFiles/boxes/filters/edit_filter_chats_list.cpp b/Telegram/SourceFiles/boxes/filters/edit_filter_chats_list.cpp index a5d0cdf87..fefe35124 100644 --- a/Telegram/SourceFiles/boxes/filters/edit_filter_chats_list.cpp +++ b/Telegram/SourceFiles/boxes/filters/edit_filter_chats_list.cpp @@ -342,7 +342,7 @@ void EditFilterChatsListController::prepareViewHook() { const auto count = int(_peers.size()); const auto rows = std::make_unique[]>(count); auto i = 0; - for (const auto history : _peers) { + for (const auto &history : _peers) { rows[i++].emplace(history); } auto pointers = std::vector(); diff --git a/Telegram/SourceFiles/boxes/peer_list_box.cpp b/Telegram/SourceFiles/boxes/peer_list_box.cpp index 6b9bb077d..6a9478952 100644 --- a/Telegram/SourceFiles/boxes/peer_list_box.cpp +++ b/Telegram/SourceFiles/boxes/peer_list_box.cpp @@ -186,7 +186,7 @@ void PeerListBox::paintEvent(QPaintEvent *e) { const auto &bg = (_controller->listSt() ? *_controller->listSt() : st::peerListBox).bg; - for (const auto rect : e->region()) { + for (const auto &rect : e->region()) { p.fillRect(rect, bg); } } @@ -1693,7 +1693,7 @@ void PeerListContent::searchQueryChanged(QString query) { }; _filterResults.reserve(minimalList->size()); - for (const auto row : *minimalList) { + for (const auto &row : *minimalList) { if (!row->special() && allSearchWordsInNames(row->peer())) { _filterResults.push_back(row); } @@ -1999,4 +1999,4 @@ void PeerListContentDelegate::peerListShowRowMenu( bool highlightRow, Fn)> destroyed) { _content->showRowMenu(row, highlightRow, std::move(destroyed)); -} \ No newline at end of file +} diff --git a/Telegram/SourceFiles/boxes/peer_list_controllers.cpp b/Telegram/SourceFiles/boxes/peer_list_controllers.cpp index 680070490..3736cd9b8 100644 --- a/Telegram/SourceFiles/boxes/peer_list_controllers.cpp +++ b/Telegram/SourceFiles/boxes/peer_list_controllers.cpp @@ -288,7 +288,7 @@ void ChatsListBoxController::rebuildRows() { auto wasEmpty = !delegate()->peerListFullRowsCount(); auto appendList = [this](auto chats) { auto count = 0; - for (const auto row : chats->all()) { + for (const auto &row : chats->all()) { if (const auto history = row->history()) { if (appendRow(history)) { ++count; @@ -389,7 +389,7 @@ void ContactsBoxController::prepare() { void ContactsBoxController::rebuildRows() { const auto appendList = [&](auto chats) { auto count = 0; - for (const auto row : chats->all()) { + for (const auto &row : chats->all()) { if (const auto history = row->history()) { if (const auto user = history->peer->asUser()) { if (appendRow(user)) { diff --git a/Telegram/SourceFiles/boxes/peer_lists_box.cpp b/Telegram/SourceFiles/boxes/peer_lists_box.cpp index 010dba90a..7311c00b5 100644 --- a/Telegram/SourceFiles/boxes/peer_lists_box.cpp +++ b/Telegram/SourceFiles/boxes/peer_lists_box.cpp @@ -283,7 +283,7 @@ void PeerListsBox::paintEvent(QPaintEvent *e) { const auto &bg = (firstController()->listSt() ? *firstController()->listSt() : st::peerListBox).bg; - for (const auto rect : e->region()) { + for (const auto &rect : e->region()) { p.fillRect(rect, bg); } } diff --git a/Telegram/SourceFiles/boxes/peers/add_participants_box.cpp b/Telegram/SourceFiles/boxes/peers/add_participants_box.cpp index 2f6782864..06e079b89 100644 --- a/Telegram/SourceFiles/boxes/peers/add_participants_box.cpp +++ b/Telegram/SourceFiles/boxes/peers/add_participants_box.cpp @@ -429,7 +429,7 @@ void AddSpecialBoxController::rebuildChatRows(not_null chat) { --count; } } - for (const auto user : participants) { + for (const auto &user : participants) { if (auto row = createRow(user)) { delegate()->peerListAppendRow(std::move(row)); } @@ -1155,7 +1155,7 @@ void AddSpecialBoxSearchController::addChatMembers( return true; }; - for (const auto user : chat->participants) { + for (const auto &user : chat->participants) { if (allWordsAreFound(user->nameWords())) { delegate()->peerListSearchAddRow(user); } @@ -1210,7 +1210,7 @@ void AddSpecialBoxSearchController::addChatsContacts() { if (!index) { return; } - for (const auto row : *index) { + for (const auto &row : *index) { if (const auto history = row->history()) { if (const auto user = history->peer->asUser()) { if (allWordsAreFound(user->nameWords())) { diff --git a/Telegram/SourceFiles/boxes/peers/edit_participants_box.cpp b/Telegram/SourceFiles/boxes/peers/edit_participants_box.cpp index 98bda8b54..f3707234e 100644 --- a/Telegram/SourceFiles/boxes/peers/edit_participants_box.cpp +++ b/Telegram/SourceFiles/boxes/peers/edit_participants_box.cpp @@ -702,7 +702,7 @@ void ParticipantsAdditionalData::migrate( _peer = channel; fillFromChannel(channel); - for (const auto user : _admins) { + for (const auto &user : _admins) { _adminRights.emplace(user, chat->defaultAdminRights(user)); if (channel->amCreator()) { _adminCanEdit.emplace(user); @@ -1197,7 +1197,7 @@ void ParticipantsBoxController::rebuildChatParticipants( --count; } } - for (const auto user : participants) { + for (const auto &user : participants) { if (auto row = createRow(user)) { delegate()->peerListAppendRow(std::move(row)); } diff --git a/Telegram/SourceFiles/boxes/share_box.cpp b/Telegram/SourceFiles/boxes/share_box.cpp index 535772e23..2fd76bd12 100644 --- a/Telegram/SourceFiles/boxes/share_box.cpp +++ b/Telegram/SourceFiles/boxes/share_box.cpp @@ -560,7 +560,7 @@ ShareBox::Inner::Inner(QWidget *parent, const Descriptor &descriptor) _chatsIndexed->addToEnd(self->owner().history(self)); } const auto addList = [&](not_null list) { - for (const auto row : list->all()) { + for (const auto &row : list->all()) { if (const auto history = row->history()) { if (!history->peer->isSelf() && _descriptor.filterCallback(history->peer)) { @@ -703,7 +703,7 @@ void ShareBox::Inner::repaintChat(not_null peer) { int ShareBox::Inner::chatIndex(not_null peer) const { int index = 0; if (_filter.isEmpty()) { - for (const auto row : _chatsIndexed->all()) { + for (const auto &row : _chatsIndexed->all()) { if (const auto history = row->history()) { if (history->peer == peer) { return index; @@ -712,7 +712,7 @@ int ShareBox::Inner::chatIndex(not_null peer) const { ++index; } } else { - for (const auto row : _filtered) { + for (const auto &row : _filtered) { if (const auto history = row->history()) { if (history->peer == peer) { return index; diff --git a/Telegram/SourceFiles/calls/calls_panel.cpp b/Telegram/SourceFiles/calls/calls_panel.cpp index 3dd75c45a..e7372636d 100644 --- a/Telegram/SourceFiles/calls/calls_panel.cpp +++ b/Telegram/SourceFiles/calls/calls_panel.cpp @@ -773,7 +773,7 @@ void Panel::paint(QRect clip) { if (!_incoming->widget()->isHidden()) { region = region.subtracted(QRegion(_incoming->widget()->geometry())); } - for (const auto rect : region) { + for (const auto &rect : region) { p.fillRect(rect, st::callBgOpaque); } if (_incoming && _incoming->widget()->isHidden()) { diff --git a/Telegram/SourceFiles/calls/group/calls_group_call.cpp b/Telegram/SourceFiles/calls/group/calls_group_call.cpp index c9efe268e..2eaba0ca1 100644 --- a/Telegram/SourceFiles/calls/group/calls_group_call.cpp +++ b/Telegram/SourceFiles/calls/group/calls_group_call.cpp @@ -3157,7 +3157,7 @@ std::variant> GroupCall::inviteUsers( }).send(); slice.clear(); }; - for (const auto user : users) { + for (const auto &user : users) { if (!count && slice.empty()) { result = user; } diff --git a/Telegram/SourceFiles/calls/group/calls_group_members.cpp b/Telegram/SourceFiles/calls/group/calls_group_members.cpp index 288bce2df..8144f1df6 100644 --- a/Telegram/SourceFiles/calls/group/calls_group_members.cpp +++ b/Telegram/SourceFiles/calls/group/calls_group_members.cpp @@ -481,7 +481,7 @@ void Members::Controller::toggleVideoEndpointActive( void Members::Controller::appendInvitedUsers() { if (const auto id = _call->id()) { - for (const auto user : _peer->owner().invitedToCallUsers(id)) { + for (const auto &user : _peer->owner().invitedToCallUsers(id)) { if (auto row = createInvitedRow(user)) { delegate()->peerListAppendRow(std::move(row)); } @@ -1149,7 +1149,7 @@ void Members::Controller::showRowMenu( return; } auto saved = base::take(_menu); - for (const auto peer : base::take(_menuCheckRowsAfterHidden)) { + for (const auto &peer : base::take(_menuCheckRowsAfterHidden)) { if (const auto row = findRow(peer)) { checkRowPosition(row); } diff --git a/Telegram/SourceFiles/calls/group/calls_group_panel.cpp b/Telegram/SourceFiles/calls/group/calls_group_panel.cpp index d6b85897c..05460ed4d 100644 --- a/Telegram/SourceFiles/calls/group/calls_group_panel.cpp +++ b/Telegram/SourceFiles/calls/group/calls_group_panel.cpp @@ -2179,7 +2179,7 @@ void Panel::paint(QRect clip) { Painter p(widget()); auto region = QRegion(clip); - for (const auto rect : region) { + for (const auto &rect : region) { p.fillRect(rect, st::groupCallBg); } } diff --git a/Telegram/SourceFiles/calls/group/calls_group_viewport_raster.cpp b/Telegram/SourceFiles/calls/group/calls_group_viewport_raster.cpp index 354e84c29..335db764e 100644 --- a/Telegram/SourceFiles/calls/group/calls_group_viewport_raster.cpp +++ b/Telegram/SourceFiles/calls/group/calls_group_viewport_raster.cpp @@ -50,7 +50,7 @@ void Viewport::RendererSW::paintFallback( } paintTile(p, tile.get(), bounding, bg); } - for (const auto rect : bg) { + for (const auto &rect : bg) { p.fillRect(rect, st::groupCallBg); } for (auto i = _tileData.begin(); i != _tileData.end();) { diff --git a/Telegram/SourceFiles/chat_helpers/emoji_sets_manager.cpp b/Telegram/SourceFiles/chat_helpers/emoji_sets_manager.cpp index 3cfb623ca..e7c9d2104 100644 --- a/Telegram/SourceFiles/chat_helpers/emoji_sets_manager.cpp +++ b/Telegram/SourceFiles/chat_helpers/emoji_sets_manager.cpp @@ -247,7 +247,7 @@ void Row::paintPreview(Painter &p) const { const auto width = st::manageEmojiPreviewWidth; const auto height = st::manageEmojiPreviewWidth; auto &&preview = ranges::views::zip(_preview, ranges::views::ints(0, int(_preview.size()))); - for (const auto &[pixmap, index] : preview) { + for (const auto [pixmap, index] : preview) { const auto row = (index / 2); const auto column = (index % 2); const auto left = x + (column ? width - st::manageEmojiPreview : 0); diff --git a/Telegram/SourceFiles/chat_helpers/field_autocomplete.cpp b/Telegram/SourceFiles/chat_helpers/field_autocomplete.cpp index 4d98c1b7c..86f6e04b1 100644 --- a/Telegram/SourceFiles/chat_helpers/field_autocomplete.cpp +++ b/Telegram/SourceFiles/chat_helpers/field_autocomplete.cpp @@ -411,7 +411,7 @@ void FieldAutocomplete::updateFiltered(bool resetScroll) { if (_chat->noParticipantInfo()) { _chat->session().api().requestFullPeer(_chat); } else if (!_chat->participants.empty()) { - for (const auto user : _chat->participants) { + for (const auto &user : _chat->participants) { if (user->isInaccessible()) continue; if (!listAllSuggestions && filterNotPassedByName(user)) continue; if (indexOfInFirstN(mrows, user, recentInlineBots) >= 0) continue; @@ -469,7 +469,7 @@ void FieldAutocomplete::updateFiltered(bool resetScroll) { _chat->session().api().requestFullPeer(_chat); } else if (!_chat->participants.empty()) { const auto &commands = _chat->botCommands(); - for (const auto user : _chat->participants) { + for (const auto &user : _chat->participants) { if (!user->isBot()) { continue; } @@ -493,7 +493,7 @@ void FieldAutocomplete::updateFiltered(bool resetScroll) { } } else { const auto &commands = _channel->mgInfo->botCommands(); - for (const auto user : _channel->mgInfo->bots) { + for (const auto &user : _channel->mgInfo->bots) { if (!user->isBot()) { continue; } diff --git a/Telegram/SourceFiles/chat_helpers/message_field.cpp b/Telegram/SourceFiles/chat_helpers/message_field.cpp index b9f146da0..9a07043f2 100644 --- a/Telegram/SourceFiles/chat_helpers/message_field.cpp +++ b/Telegram/SourceFiles/chat_helpers/message_field.cpp @@ -331,7 +331,7 @@ void InitSpellchecker( bool HasSendText(not_null field) { const auto &text = field->getTextWithTags().text; - for (const auto ch : text) { + for (const auto &ch : text) { const auto code = ch.unicode(); if (code != ' ' && code != '\n' diff --git a/Telegram/SourceFiles/chat_helpers/stickers_dice_pack.cpp b/Telegram/SourceFiles/chat_helpers/stickers_dice_pack.cpp index bd9120551..4c2335b55 100644 --- a/Telegram/SourceFiles/chat_helpers/stickers_dice_pack.cpp +++ b/Telegram/SourceFiles/chat_helpers/stickers_dice_pack.cpp @@ -86,7 +86,7 @@ void DicePack::applySet(const MTPDmessages_stickerSet &data) { if (index < 0 || index > 6) { return; } - for (const auto id : data.vdocuments().v) { + for (const auto &id : data.vdocuments().v) { if (const auto document = documents.take(id.v)) { _map.emplace(index, *document); } diff --git a/Telegram/SourceFiles/core/application.cpp b/Telegram/SourceFiles/core/application.cpp index 11577f81b..8509c46d8 100644 --- a/Telegram/SourceFiles/core/application.cpp +++ b/Telegram/SourceFiles/core/application.cpp @@ -1032,7 +1032,7 @@ void Application::registerLeaveSubscription(not_null widget) { const auto check = [=](not_null e) { if (e->type() == QEvent::Leave) { if (const auto taken = _leaveFilters.take(window)) { - for (const auto weak : taken->registered) { + for (const auto &weak : taken->registered) { if (const auto widget = weak.data()) { QEvent ev(QEvent::Leave); QCoreApplication::sendEvent(widget, &ev); diff --git a/Telegram/SourceFiles/core/changelogs.cpp b/Telegram/SourceFiles/core/changelogs.cpp index 04618706e..1dbe2f3d4 100644 --- a/Telegram/SourceFiles/core/changelogs.cpp +++ b/Telegram/SourceFiles/core/changelogs.cpp @@ -192,7 +192,7 @@ void Changelogs::addLocalLog(const QString &text) { }; void Changelogs::addBetaLogs() { - for (const auto [version, changes] : BetaLogs()) { + for (const auto &[version, changes] : BetaLogs()) { addBetaLog(version, changes); } } diff --git a/Telegram/SourceFiles/core/core_settings.cpp b/Telegram/SourceFiles/core/core_settings.cpp index ba1dfee50..236137f3f 100644 --- a/Telegram/SourceFiles/core/core_settings.cpp +++ b/Telegram/SourceFiles/core/core_settings.cpp @@ -82,7 +82,7 @@ QByteArray Settings::serialize() const { auto recentEmojiPreloadGenerated = std::vector(); if (_recentEmojiPreload.empty()) { recentEmojiPreloadGenerated.reserve(_recentEmoji.size()); - for (const auto [emoji, rating] : _recentEmoji) { + for (const auto &[emoji, rating] : _recentEmoji) { recentEmojiPreloadGenerated.push_back({ emoji->id(), rating }); } } @@ -713,7 +713,7 @@ EmojiPack Settings::recentEmojiSection() const { auto result = EmojiPack(); result.reserve(recent.size()); - for (const auto [emoji, rating] : recent) { + for (const auto &[emoji, rating] : recent) { result.push_back(emoji); } return result; diff --git a/Telegram/SourceFiles/data/data_changes.cpp b/Telegram/SourceFiles/data/data_changes.cpp index 8686f0ec0..3f4518b5c 100644 --- a/Telegram/SourceFiles/data/data_changes.cpp +++ b/Telegram/SourceFiles/data/data_changes.cpp @@ -78,7 +78,7 @@ rpl::producer Changes::Manager::flagsValue( template void Changes::Manager::sendNotifications() { - for (const auto [data, flags] : base::take(_updates)) { + for (const auto &[data, flags] : base::take(_updates)) { _stream.fire({ data, flags }); } } diff --git a/Telegram/SourceFiles/data/data_channel.cpp b/Telegram/SourceFiles/data/data_channel.cpp index 1aacac888..4dfc5c38b 100644 --- a/Telegram/SourceFiles/data/data_channel.cpp +++ b/Telegram/SourceFiles/data/data_channel.cpp @@ -664,7 +664,7 @@ QString ChannelData::invitePeekHash() const { void ChannelData::privateErrorReceived() { if (const auto expires = invitePeekExpires()) { const auto hash = invitePeekHash(); - for (const auto window : session().windows()) { + for (const auto &window : session().windows()) { clearInvitePeek(); Api::CheckChatInvite(window, hash, this); return; diff --git a/Telegram/SourceFiles/data/data_chat_filters.cpp b/Telegram/SourceFiles/data/data_chat_filters.cpp index 47e234837..d54da1ce9 100644 --- a/Telegram/SourceFiles/data/data_chat_filters.cpp +++ b/Telegram/SourceFiles/data/data_chat_filters.cpp @@ -122,18 +122,18 @@ MTPDialogFilter ChatFilter::tl(FilterId replaceId) const { auto always = _always; auto pinned = QVector(); pinned.reserve(_pinned.size()); - for (const auto history : _pinned) { + for (const auto &history : _pinned) { pinned.push_back(history->peer->input); always.remove(history); } auto include = QVector(); include.reserve(always.size()); - for (const auto history : always) { + for (const auto &history : always) { include.push_back(history->peer->input); } auto never = QVector(); never.reserve(_never.size()); - for (const auto history : _never) { + for (const auto &history : _never) { never.push_back(history->peer->input); } return MTP_dialogFilter( @@ -417,7 +417,7 @@ bool ChatFilters::applyOrder(const QVector &order) { &ChatFilter::id ) | ranges::to_vector; auto b = indices.begin(), e = indices.end(); - for (const auto id : order) { + for (const auto &id : order) { const auto i = ranges::find(b, e, id.v); if (i == e) { return false; @@ -428,7 +428,7 @@ bool ChatFilters::applyOrder(const QVector &order) { } auto changed = false; auto begin = _list.begin(), end = _list.end(); - for (const auto id : order) { + for (const auto &id : order) { const auto i = ranges::find(begin, end, id.v, &ChatFilter::id); Assert(i != end); if (i != begin) { @@ -526,7 +526,7 @@ bool ChatFilters::loadNextExceptions(bool chatsListLoaded) { const auto i = ranges::find(_list, id, &ChatFilter::id); if (i != end(_list)) { result.reserve(i->always().size()); - for (const auto history : i->always()) { + for (const auto &history : i->always()) { if (!history->folderKnown()) { inputs.push_back( MTP_inputDialogPeer(history->peer->input)); diff --git a/Telegram/SourceFiles/data/data_cloud_themes.cpp b/Telegram/SourceFiles/data/data_cloud_themes.cpp index d469a3382..2ebddb8ce 100644 --- a/Telegram/SourceFiles/data/data_cloud_themes.cpp +++ b/Telegram/SourceFiles/data/data_cloud_themes.cpp @@ -49,7 +49,7 @@ CloudTheme CloudTheme::Parse( if (const auto settings = data.vsettings()) { settings->match([&](const MTPDthemeSettings &data) { if (const auto colors = data.vmessage_colors()) { - for (const auto color : colors->v) { + for (const auto &color : colors->v) { result.push_back(ColorFromSerialized(color)); } } diff --git a/Telegram/SourceFiles/data/data_document.cpp b/Telegram/SourceFiles/data/data_document.cpp index e8fd3cfa0..a132650df 100644 --- a/Telegram/SourceFiles/data/data_document.cpp +++ b/Telegram/SourceFiles/data/data_document.cpp @@ -388,7 +388,7 @@ void DocumentData::setattributes( 0x2066, // LTR Isolate 0x2067, // RTL Isolate }; - for (const auto ch : controls) { + for (const auto &ch : controls) { _filename = std::move(_filename).replace(ch, "_"); } }, [&](const MTPDdocumentAttributeHasStickers &data) { diff --git a/Telegram/SourceFiles/data/data_drafts.h b/Telegram/SourceFiles/data/data_drafts.h index 3b7b17a3b..7641b1eea 100644 --- a/Telegram/SourceFiles/data/data_drafts.h +++ b/Telegram/SourceFiles/data/data_drafts.h @@ -126,7 +126,7 @@ private: using HistoryDrafts = base::flat_map>; inline bool draftStringIsEmpty(const QString &text) { - for (const auto ch : text) { + for (const auto &ch : text) { if (!ch.isSpace()) { return false; } diff --git a/Telegram/SourceFiles/data/data_groups.cpp b/Telegram/SourceFiles/data/data_groups.cpp index 650a4f889..3a4ef25bc 100644 --- a/Telegram/SourceFiles/data/data_groups.cpp +++ b/Telegram/SourceFiles/data/data_groups.cpp @@ -140,7 +140,7 @@ const Group *Groups::find(not_null item) const { } void Groups::refreshViews(const HistoryItemsList &items) { - for (const auto item : items) { + for (const auto &item : items) { _data->requestItemViewRefresh(item); } } diff --git a/Telegram/SourceFiles/data/data_histories.cpp b/Telegram/SourceFiles/data/data_histories.cpp index ce38067b4..04e7fb811 100644 --- a/Telegram/SourceFiles/data/data_histories.cpp +++ b/Telegram/SourceFiles/data/data_histories.cpp @@ -333,7 +333,7 @@ void Histories::sendDialogRequests() { } const auto finalize = [=] { - for (const auto history : histories) { + for (const auto &history : histories) { const auto state = lookup(history); if (!state || !state->postponedRequestEntry) { dialogEntryApplied(history); @@ -667,7 +667,7 @@ void Histories::deleteMessages(const MessageIdsList &ids, bool revoke) { remove.reserve(ids.size()); base::flat_map, QVector> idsByPeer; base::flat_map, QVector> scheduledIdsByPeer; - for (const auto itemId : ids) { + for (const auto &itemId : ids) { if (const auto item = _owner->message(itemId)) { const auto history = item->history(); if (item->isScheduled()) { diff --git a/Telegram/SourceFiles/data/data_replies_list.cpp b/Telegram/SourceFiles/data/data_replies_list.cpp index 7b0a5639f..7f47cfeab 100644 --- a/Telegram/SourceFiles/data/data_replies_list.cpp +++ b/Telegram/SourceFiles/data/data_replies_list.cpp @@ -124,7 +124,7 @@ void RepliesList::appendLocalMessages(MessagesSlice &slice) { return; } slice.ids.reserve(local.size()); - for (const auto item : local) { + for (const auto &item : local) { if (item->replyToTop() != _rootId) { continue; } @@ -142,7 +142,7 @@ void RepliesList::appendLocalMessages(MessagesSlice &slice) { dates.push_back(message->date()); } - for (const auto item : local) { + for (const auto &item : local) { if (item->replyToTop() != _rootId) { continue; } @@ -254,7 +254,7 @@ void RepliesList::injectRootMessage(not_null viewer) { injectRootDivider(root, slice); if (const auto group = _history->owner().groups().find(root)) { - for (const auto item : ranges::views::reverse(group->items)) { + for (const auto &item : ranges::views::reverse(group->items)) { slice->ids.push_back(item->fullId()); } viewer->injectedForRoot = group->items.size(); diff --git a/Telegram/SourceFiles/data/data_scheduled_messages.cpp b/Telegram/SourceFiles/data/data_scheduled_messages.cpp index a468c76bc..756cede9b 100644 --- a/Telegram/SourceFiles/data/data_scheduled_messages.cpp +++ b/Telegram/SourceFiles/data/data_scheduled_messages.cpp @@ -495,7 +495,7 @@ void ScheduledMessages::updated( const base::flat_set> &added, const base::flat_set> &clear) { if (!clear.empty()) { - for (const auto item : clear) { + for (const auto &item : clear) { item->destroy(); } } diff --git a/Telegram/SourceFiles/data/data_session.cpp b/Telegram/SourceFiles/data/data_session.cpp index d8a609fd6..78b0f28f5 100644 --- a/Telegram/SourceFiles/data/data_session.cpp +++ b/Telegram/SourceFiles/data/data_session.cpp @@ -1162,7 +1162,7 @@ void Session::setupUserIsContactViewer() { }) | rpl::start_with_next([=](not_null user) { const auto i = _contactViews.find(peerToUser(user->id)); if (i != _contactViews.end()) { - for (const auto view : i->second) { + for (const auto &view : i->second) { requestViewResize(view); } } @@ -1211,7 +1211,7 @@ void Session::documentLoadSettingsChanged() { void Session::notifyPhotoLayoutChanged(not_null photo) { if (const auto i = _photoItems.find(photo); i != end(_photoItems)) { - for (const auto item : i->second) { + for (const auto &item : i->second) { notifyItemLayoutChange(item); } } @@ -1220,7 +1220,7 @@ void Session::notifyPhotoLayoutChanged(not_null photo) { void Session::requestPhotoViewRepaint(not_null photo) { const auto i = _photoItems.find(photo); if (i != end(_photoItems)) { - for (const auto item : i->second) { + for (const auto &item : i->second) { requestItemRepaint(item); } } @@ -1230,13 +1230,13 @@ void Session::notifyDocumentLayoutChanged( not_null document) { const auto i = _documentItems.find(document); if (i != end(_documentItems)) { - for (const auto item : i->second) { + for (const auto &item : i->second) { notifyItemLayoutChange(item); } } if (const auto items = InlineBots::Layout::documentItems()) { if (const auto i = items->find(document); i != items->end()) { - for (const auto item : i->second) { + for (const auto &item : i->second) { item->layoutChanged(); } } @@ -1247,7 +1247,7 @@ void Session::requestDocumentViewRepaint( not_null document) { const auto i = _documentItems.find(document); if (i != end(_documentItems)) { - for (const auto item : i->second) { + for (const auto &item : i->second) { requestItemRepaint(item); } } @@ -1255,7 +1255,7 @@ void Session::requestDocumentViewRepaint( void Session::requestPollViewRepaint(not_null poll) { if (const auto i = _pollViews.find(poll); i != _pollViews.end()) { - for (const auto view : i->second) { + for (const auto &view : i->second) { requestViewResize(view); } } @@ -1500,7 +1500,7 @@ rpl::producer> Session::historyChanged() const { } void Session::sendHistoryChangeNotifications() { - for (const auto history : base::take(_historiesChanged)) { + for (const auto &history : base::take(_historiesChanged)) { _historyChanged.fire_copy(history); } } @@ -1531,12 +1531,12 @@ void Session::unloadHeavyViewParts( delegate, [](not_null element) { return element->delegate(); }); if (remove == _heavyViewParts.size()) { - for (const auto view : base::take(_heavyViewParts)) { + for (const auto &view : base::take(_heavyViewParts)) { view->unloadHeavyPart(); } } else { auto remove = std::vector>(); - for (const auto view : _heavyViewParts) { + for (const auto &view : _heavyViewParts) { if (view->delegate() == delegate) { remove.push_back(view); } @@ -1555,7 +1555,7 @@ void Session::unloadHeavyViewParts( return; } auto remove = std::vector>(); - for (const auto view : _heavyViewParts) { + for (const auto &view : _heavyViewParts) { if (view->delegate() == delegate && !delegate->elementIntersectsRange(view, from, till)) { remove.push_back(view); @@ -1942,7 +1942,7 @@ void Session::processMessagesDeleted( } auto historiesToCheck = base::flat_set>(); - for (const auto messageId : data) { + for (const auto &messageId : data) { const auto i = list ? list->find(messageId.v) : Messages::iterator(); if (list && i != list->end()) { const auto history = i->second->history(); @@ -1954,7 +1954,7 @@ void Session::processMessagesDeleted( affected->unknownMessageDeleted(messageId.v); } } - for (const auto history : historiesToCheck) { + for (const auto &history : historiesToCheck) { history->requestChatListMessage(); } } @@ -1967,7 +1967,7 @@ void Session::removeDependencyMessage(not_null item) { const auto items = std::move(i->second); _dependentMessages.erase(i); - for (const auto dependent : items) { + for (const auto &dependent : items) { dependent->dependencyItemRemoved(item); } } @@ -2030,7 +2030,7 @@ HistoryItem *Session::message(FullMsgId itemId) const { void Session::updateDependentMessages(not_null item) { const auto i = _dependentMessages.find(item); if (i != end(_dependentMessages)) { - for (const auto dependent : i->second) { + for (const auto &dependent : i->second) { dependent->updateDependencyItem(); } } @@ -3169,7 +3169,7 @@ void Session::applyUpdate(const MTPDupdateChatParticipants &update) { }); if (const auto chat = chatLoaded(chatId)) { ApplyChatUpdate(chat, update); - for (const auto user : chat->participants) { + for (const auto &user : chat->participants) { if (user->isBot() && !user->botInfo->inited) { _session->api().requestFullPeer(user); } @@ -3434,7 +3434,7 @@ void Session::documentMessageRemoved(not_null document) { void Session::checkPlayingAnimations() { auto check = base::flat_set>(); - for (const auto view : _heavyViewParts) { + for (const auto &view : _heavyViewParts) { if (const auto media = view->media()) { if (const auto document = media->getDocument()) { if (document->isAnimation() || document->isVideoFile()) { @@ -3447,7 +3447,7 @@ void Session::checkPlayingAnimations() { } } } - for (const auto view : check) { + for (const auto &view : check) { view->media()->checkAnimation(); } } @@ -3455,7 +3455,7 @@ void Session::checkPlayingAnimations() { HistoryItem *Session::findWebPageItem(not_null page) const { const auto i = _webpageItems.find(page); if (i != _webpageItems.end()) { - for (const auto item : i->second) { + for (const auto &item : i->second) { if (IsServerMsgId(item->id)) { return item; } @@ -3514,25 +3514,25 @@ void Session::notifyPollUpdateDelayed(not_null poll) { } void Session::sendWebPageGamePollNotifications() { - for (const auto page : base::take(_webpagesUpdated)) { + for (const auto &page : base::take(_webpagesUpdated)) { _webpageUpdates.fire_copy(page); const auto i = _webpageViews.find(page); if (i != _webpageViews.end()) { - for (const auto view : i->second) { + for (const auto &view : i->second) { requestViewResize(view); } } } - for (const auto game : base::take(_gamesUpdated)) { + for (const auto &game : base::take(_gamesUpdated)) { if (const auto i = _gameViews.find(game); i != _gameViews.end()) { - for (const auto view : i->second) { + for (const auto &view : i->second) { requestViewResize(view); } } } - for (const auto poll : base::take(_pollsUpdated)) { + for (const auto &poll : base::take(_pollsUpdated)) { if (const auto i = _pollViews.find(poll); i != _pollViews.end()) { - for (const auto view : i->second) { + for (const auto &view : i->second) { requestViewResize(view); } } diff --git a/Telegram/SourceFiles/data/stickers/data_stickers.cpp b/Telegram/SourceFiles/data/stickers/data_stickers.cpp index 346b685f7..1f6cf60d5 100644 --- a/Telegram/SourceFiles/data/stickers/data_stickers.cpp +++ b/Telegram/SourceFiles/data/stickers/data_stickers.cpp @@ -166,7 +166,7 @@ void Stickers::incrementSticker(not_null document) { } set->stickers.push_front(document); if (const auto emojiList = getEmojiListFromSet(document)) { - for (const auto emoji : *emojiList) { + for (const auto &emoji : *emojiList) { set->emoji[emoji].push_front(document); } } else if (!removedFromEmoji.empty()) { diff --git a/Telegram/SourceFiles/dialogs/dialogs_indexed_list.cpp b/Telegram/SourceFiles/dialogs/dialogs_indexed_list.cpp index 25e732ef8..843646f0d 100644 --- a/Telegram/SourceFiles/dialogs/dialogs_indexed_list.cpp +++ b/Telegram/SourceFiles/dialogs/dialogs_indexed_list.cpp @@ -26,7 +26,7 @@ RowsByLetter IndexedList::addToEnd(Key key) { } auto result = RowsByLetter{ _list.addToEnd(key) }; - for (const auto ch : key.entry()->chatListFirstLetters()) { + for (const auto &ch : key.entry()->chatListFirstLetters()) { auto j = _index.find(ch); if (j == _index.cend()) { j = _index.emplace(ch, _sortMode, _filterId).first; @@ -42,7 +42,7 @@ Row *IndexedList::addByName(Key key) { } const auto result = _list.addByName(key); - for (const auto ch : key.entry()->chatListFirstLetters()) { + for (const auto &ch : key.entry()->chatListFirstLetters()) { auto j = _index.find(ch); if (j == _index.cend()) { j = _index.emplace(ch, _sortMode, _filterId).first; @@ -63,7 +63,7 @@ void IndexedList::adjustByDate(const RowsByLetter &links) { void IndexedList::moveToTop(Key key) { if (_list.moveToTop(key)) { - for (const auto ch : key.entry()->chatListFirstLetters()) { + for (const auto &ch : key.entry()->chatListFirstLetters()) { if (auto it = _index.find(ch); it != _index.cend()) { it->second.moveToTop(key); } @@ -121,7 +121,7 @@ void IndexedList::adjustByName( auto toRemove = oldLetters; auto toAdd = base::flat_set(); - for (const auto ch : key.entry()->chatListFirstLetters()) { + for (const auto &ch : key.entry()->chatListFirstLetters()) { auto j = toRemove.find(ch); if (j == toRemove.cend()) { toAdd.insert(ch); @@ -158,7 +158,7 @@ void IndexedList::adjustNames( auto toRemove = oldLetters; auto toAdd = base::flat_set(); - for (const auto ch : key.entry()->chatListFirstLetters()) { + for (const auto &ch : key.entry()->chatListFirstLetters()) { auto j = toRemove.find(ch); if (j == toRemove.cend()) { toAdd.insert(ch); @@ -188,7 +188,7 @@ void IndexedList::adjustNames( void IndexedList::del(Key key, Row *replacedBy) { if (_list.del(key, replacedBy)) { - for (const auto ch : key.entry()->chatListFirstLetters()) { + for (const auto &ch : key.entry()->chatListFirstLetters()) { if (auto it = _index.find(ch); it != _index.cend()) { it->second.del(key, replacedBy); } @@ -225,7 +225,7 @@ std::vector> IndexedList::filtered( return result; } result.reserve(minimal->size()); - for (const auto row : *minimal) { + for (const auto &row : *minimal) { const auto &nameWords = row->entry()->chatListNameWords(); const auto found = [&](const QString &word) { for (const auto &name : nameWords) { diff --git a/Telegram/SourceFiles/dialogs/dialogs_inner_widget.cpp b/Telegram/SourceFiles/dialogs/dialogs_inner_widget.cpp index 5c30168d7..73bdcaa28 100644 --- a/Telegram/SourceFiles/dialogs/dialogs_inner_widget.cpp +++ b/Telegram/SourceFiles/dialogs/dialogs_inner_widget.cpp @@ -61,7 +61,7 @@ constexpr auto kStartReorderThreshold = 30; int FixedOnTopDialogsCount(not_null list) { auto result = 0; - for (const auto row : *list) { + for (const auto &row : *list) { if (!row->entry()->fixedOnTopIndex()) { break; } @@ -74,7 +74,7 @@ int PinnedDialogsCount( FilterId filterId, not_null list) { auto result = 0; - for (const auto row : *list) { + for (const auto &row : *list) { if (row->entry()->fixedOnTopIndex()) { continue; } else if (!row->entry()->isPinnedDialog(filterId)) { @@ -341,7 +341,7 @@ int InnerWidget::dialogsOffset() const { int InnerWidget::fixedOnTopCount() const { auto result = 0; - for (const auto row : *shownDialogs()) { + for (const auto &row : *shownDialogs()) { if (row->entry()->fixedOnTopIndex()) { ++result; } else { @@ -1103,7 +1103,7 @@ int InnerWidget::countPinnedIndex(Row *ofRow) { return -1; } auto result = 0; - for (const auto row : *shownDialogs()) { + for (const auto &row : *shownDialogs()) { if (row->entry()->fixedOnTopIndex()) { continue; } else if (!row->entry()->isPinnedDialog(_filterId)) { diff --git a/Telegram/SourceFiles/export/output/export_output_html.cpp b/Telegram/SourceFiles/export/output/export_output_html.cpp index b14caa18c..f49945551 100644 --- a/Telegram/SourceFiles/export/output/export_output_html.cpp +++ b/Telegram/SourceFiles/export/output/export_output_html.cpp @@ -397,7 +397,7 @@ QByteArray PeersMap::wrapUserName(UserId userId) const { QByteArray PeersMap::wrapUserNames(const std::vector &data) const { auto list = std::vector(); - for (const auto userId : data) { + for (const auto &userId : data) { list.push_back(wrapUserName(userId)); } return SerializeList(list); diff --git a/Telegram/SourceFiles/export/output/export_output_json.cpp b/Telegram/SourceFiles/export/output/export_output_json.cpp index 4eb287498..9ac9ec3e5 100644 --- a/Telegram/SourceFiles/export/output/export_output_json.cpp +++ b/Telegram/SourceFiles/export/output/export_output_json.cpp @@ -324,7 +324,7 @@ QByteArray SerializeMessage( const std::vector &data, const QByteArray &label = "members") { auto list = std::vector(); - for (const auto userId : data) { + for (const auto &userId : data) { list.push_back(wrapUserName(userId)); } pushBare(label, SerializeArray(context, list)); diff --git a/Telegram/SourceFiles/history/admin_log/history_admin_log_filter.cpp b/Telegram/SourceFiles/history/admin_log/history_admin_log_filter.cpp index f13746003..69c81cd14 100644 --- a/Telegram/SourceFiles/history/admin_log/history_admin_log_filter.cpp +++ b/Telegram/SourceFiles/history/admin_log/history_admin_log_filter.cpp @@ -299,7 +299,7 @@ void FilterBox::Inner::createAllUsersCheckbox(const FilterValue &filter) { } void FilterBox::Inner::createAdminsCheckboxes(const std::vector> &admins, const FilterValue &filter) { - for (const auto user : admins) { + for (const auto &user : admins) { const auto checked = filter.allUsers || base::contains(filter.admins, user); const auto checkbox = addRow( object_ptr(this, user, checked), diff --git a/Telegram/SourceFiles/history/history.cpp b/Telegram/SourceFiles/history/history.cpp index ccc0beaf0..420968ae4 100644 --- a/Telegram/SourceFiles/history/history.cpp +++ b/Telegram/SourceFiles/history/history.cpp @@ -1236,7 +1236,7 @@ void History::addOlderSlice(const QVector &slice) { if (const auto added = createItems(slice); !added.empty()) { startBuildingFrontBlock(added.size()); - for (const auto item : added) { + for (const auto &item : added) { addItemToBlock(item); } finishBuildingFrontBlock(); @@ -1269,7 +1269,7 @@ void History::addNewerSlice(const QVector &slice) { if (const auto added = createItems(slice); !added.empty()) { Assert(!isBuildingFrontBlock()); - for (const auto item : added) { + for (const auto &item : added) { addItemToBlock(item); } @@ -1315,7 +1315,7 @@ void History::addItemsToLists( // lastParticipants are displayed in Profile as members list. markupSenders = &peer->asChannel()->mgInfo->markupSenders; } - for (const auto item : ranges::views::reverse(items)) { + for (const auto &item : ranges::views::reverse(items)) { item->addToUnreadMentions(UnreadMentionType::Existing); if (item->from()->id) { if (lastAuthors) { // chats @@ -1389,7 +1389,7 @@ void History::checkAddAllToUnreadMentions() { void History::addToSharedMedia( const std::vector> &items) { std::vector medias[Storage::kSharedMediaTypeCount]; - for (const auto item : items) { + for (const auto &item : items) { if (const auto types = item->sharedMediaTypes()) { for (auto i = 0; i != Storage::kSharedMediaTypeCount; ++i) { const auto type = static_cast(i); @@ -1459,7 +1459,7 @@ bool History::readInboxTillNeedsRequest(MsgId tillId) { void History::readClientSideMessages() { auto &histories = owner().histories(); - for (const auto item : _localMessages) { + for (const auto &item : _localMessages) { histories.readClientSideMessage(item); } } @@ -3040,12 +3040,12 @@ void History::clear(ClearType type) { } else { // Leave the 'sending' messages in local messages. auto local = base::flat_set>(); - for (const auto item : _localMessages) { + for (const auto &item : _localMessages) { if (!item->isSending()) { local.emplace(item); } } - for (const auto item : local) { + for (const auto &item : local) { item->destroy(); } _notifications.clear(); diff --git a/Telegram/SourceFiles/history/history_inner_widget.cpp b/Telegram/SourceFiles/history/history_inner_widget.cpp index bc9825ee2..6ba9f5da5 100644 --- a/Telegram/SourceFiles/history/history_inner_widget.cpp +++ b/Telegram/SourceFiles/history/history_inner_widget.cpp @@ -2090,7 +2090,7 @@ TextForMimeData HistoryInner::getSelectedText() const { wrapItem(group->items.back(), HistoryGroupText(group)); }; - for (const auto [item, selection] : selected) { + for (const auto &[item, selection] : selected) { if (const auto group = session().data().groups().find(item)) { if (groups.contains(group)) { continue; @@ -3183,7 +3183,7 @@ bool HistoryInner::isSelected( bool HistoryInner::isSelectedGroup( not_null toItems, not_null group) const { - for (const auto other : group->items) { + for (const auto &other : group->items) { if (!isSelected(toItems, other)) { return false; } @@ -3272,7 +3272,7 @@ void HistoryInner::changeSelectionAsGroup( } auto total = int(toItems->size()); const auto canSelect = [&] { - for (const auto other : group->items) { + for (const auto &other : group->items) { if (!goodForSelection(toItems, other, total)) { return false; } @@ -3280,11 +3280,11 @@ void HistoryInner::changeSelectionAsGroup( return (total <= MaxSelectedItems); }(); if (action == SelectAction::Select && canSelect) { - for (const auto other : group->items) { + for (const auto &other : group->items) { addToSelection(toItems, other); } } else { - for (const auto other : group->items) { + for (const auto &other : group->items) { removeFromSelection(toItems, other); } } diff --git a/Telegram/SourceFiles/history/history_message.cpp b/Telegram/SourceFiles/history/history_message.cpp index aac094bc5..f79d5ed91 100644 --- a/Telegram/SourceFiles/history/history_message.cpp +++ b/Telegram/SourceFiles/history/history_message.cpp @@ -104,7 +104,7 @@ namespace { } [[nodiscard]] bool HasInlineItems(const HistoryItemsList &items) { - for (const auto item : items) { + for (const auto &item : items) { if (item->viaBot()) { return true; } @@ -131,7 +131,7 @@ QString GetErrorTextForSending( return tr::lng_forward_cant(tr::now); } - for (const auto item : items) { + for (const auto &item : items) { if (const auto media = item->media()) { const auto error = media->errorTextForForward(peer); if (!error.isEmpty() && error != qstr("skip")) { @@ -161,7 +161,7 @@ QString GetErrorTextForSending( } else if (items.size() > 1) { const auto albumForward = [&] { if (const auto groupId = items.front()->groupId()) { - for (const auto item : items) { + for (const auto &item : items) { if (item->groupId() != groupId) { return false; } @@ -276,7 +276,7 @@ void FastShareMessage(not_null item) { : MTPmessages_ForwardMessages::Flag(0)); auto msgIds = QVector(); msgIds.reserve(data->msgIds.size()); - for (const auto fullId : data->msgIds) { + for (const auto &fullId : data->msgIds) { msgIds.push_back(MTP_int(fullId.msg)); } auto generateRandom = [&] { diff --git a/Telegram/SourceFiles/history/history_service.cpp b/Telegram/SourceFiles/history/history_service.cpp index 56e85e476..8775b3c02 100644 --- a/Telegram/SourceFiles/history/history_service.cpp +++ b/Telegram/SourceFiles/history/history_service.cpp @@ -382,7 +382,7 @@ void HistoryService::setMessageByAction(const MTPmessageAction &action) { const auto callId = CallIdFromInput(action.vcall()); const auto owner = &history()->owner(); const auto peer = history()->peer; - for (const auto id : action.vusers().v) { + for (const auto &id : action.vusers().v) { const auto user = owner->user(id.v); if (callId) { owner->registerInvitedToCallUser(callId, peer, user); diff --git a/Telegram/SourceFiles/history/history_widget.cpp b/Telegram/SourceFiles/history/history_widget.cpp index 78293d0a8..6835a7ba6 100644 --- a/Telegram/SourceFiles/history/history_widget.cpp +++ b/Telegram/SourceFiles/history/history_widget.cpp @@ -5002,7 +5002,7 @@ void HistoryWidget::revealItemsCallback() { } void HistoryWidget::startItemRevealAnimations() { - for (const auto item : base::take(_itemRevealPending)) { + for (const auto &item : base::take(_itemRevealPending)) { if (const auto view = item->mainView()) { if (const auto top = _list->itemTop(view); top >= 0) { if (const auto height = view->height()) { diff --git a/Telegram/SourceFiles/history/view/history_view_list_widget.cpp b/Telegram/SourceFiles/history/view/history_view_list_widget.cpp index 565049975..b0ece7340 100644 --- a/Telegram/SourceFiles/history/view/history_view_list_widget.cpp +++ b/Telegram/SourceFiles/history/view/history_view_list_widget.cpp @@ -884,7 +884,7 @@ bool ListWidget::overSelectedItems() const { bool ListWidget::isSelectedGroup( const SelectedMap &applyTo, not_null group) const { - for (const auto other : group->items) { + for (const auto &other : group->items) { if (!applyTo.contains(other->fullId())) { return false; } @@ -970,7 +970,7 @@ void ListWidget::changeSelectionAsGroup( } auto already = int(applyTo.size()); const auto canSelect = [&] { - for (const auto other : group->items) { + for (const auto &other : group->items) { if (!isGoodForSelection(applyTo, other, already)) { return false; } @@ -978,11 +978,11 @@ void ListWidget::changeSelectionAsGroup( return true; }(); if (action == SelectAction::Select && canSelect) { - for (const auto other : group->items) { + for (const auto &other : group->items) { addToSelection(applyTo, other); } } else { - for (const auto other : group->items) { + for (const auto &other : group->items) { removeFromSelection(applyTo, other->fullId()); } } @@ -1440,7 +1440,7 @@ void ListWidget::resizeToWidth(int newWidth, int minHeight) { } void ListWidget::startItemRevealAnimations() { - for (const auto view : base::take(_itemRevealPending)) { + for (const auto &view : base::take(_itemRevealPending)) { if (const auto height = view->height()) { if (!_itemRevealAnimations.contains(view)) { auto &animation = _itemRevealAnimations[view]; @@ -1731,7 +1731,7 @@ void ListWidget::applyDragSelection() { void ListWidget::applyDragSelection(SelectedMap &applyTo) const { if (_dragSelectAction == DragSelectAction::Selecting) { - for (const auto itemId : _dragSelected) { + for (const auto &itemId : _dragSelected) { if (applyTo.size() >= MaxSelectedItems) { break; } else if (!applyTo.contains(itemId)) { @@ -1741,7 +1741,7 @@ void ListWidget::applyDragSelection(SelectedMap &applyTo) const { } } } else if (_dragSelectAction == DragSelectAction::Deselecting) { - for (const auto itemId : _dragSelected) { + for (const auto &itemId : _dragSelected) { removeFromSelection(applyTo, itemId); } } @@ -2163,12 +2163,12 @@ void ListWidget::updateDragSelection( }; const auto changeGroup = [&](not_null item, bool add) { if (const auto group = groups.find(item)) { - for (const auto item : group->items) { + for (const auto &item : group->items) { if (!_delegate->listIsItemGoodForSelection(item)) { return; } } - for (const auto item : group->items) { + for (const auto &item : group->items) { changeItem(item, add); } } else if (_delegate->listIsItemGoodForSelection(item)) { diff --git a/Telegram/SourceFiles/history/view/history_view_pinned_section.cpp b/Telegram/SourceFiles/history/view/history_view_pinned_section.cpp index 41a0481f0..09d3e5ace 100644 --- a/Telegram/SourceFiles/history/view/history_view_pinned_section.cpp +++ b/Telegram/SourceFiles/history/view/history_view_pinned_section.cpp @@ -622,7 +622,7 @@ bool PinnedWidget::listIsLessInOrder( void PinnedWidget::listSelectionChanged(SelectedItems &&items) { HistoryView::TopBarWidget::SelectedState state; state.count = items.size(); - for (const auto item : items) { + for (const auto &item : items) { if (item.canDelete) { ++state.canDeleteCount; } diff --git a/Telegram/SourceFiles/history/view/history_view_replies_section.cpp b/Telegram/SourceFiles/history/view/history_view_replies_section.cpp index 32fd90008..5ca38d157 100644 --- a/Telegram/SourceFiles/history/view/history_view_replies_section.cpp +++ b/Telegram/SourceFiles/history/view/history_view_replies_section.cpp @@ -1785,7 +1785,7 @@ bool RepliesWidget::listIsLessInOrder( void RepliesWidget::listSelectionChanged(SelectedItems &&items) { HistoryView::TopBarWidget::SelectedState state; state.count = items.size(); - for (const auto item : items) { + for (const auto &item : items) { if (item.canDelete) { ++state.canDeleteCount; } diff --git a/Telegram/SourceFiles/history/view/history_view_scheduled_section.cpp b/Telegram/SourceFiles/history/view/history_view_scheduled_section.cpp index 5ef556756..b1cc6cc53 100644 --- a/Telegram/SourceFiles/history/view/history_view_scheduled_section.cpp +++ b/Telegram/SourceFiles/history/view/history_view_scheduled_section.cpp @@ -1150,7 +1150,7 @@ bool ScheduledWidget::listIsLessInOrder( void ScheduledWidget::listSelectionChanged(SelectedItems &&items) { HistoryView::TopBarWidget::SelectedState state; state.count = items.size(); - for (const auto item : items) { + for (const auto &item : items) { if (item.canDelete) { ++state.canDeleteCount; } diff --git a/Telegram/SourceFiles/history/view/history_view_top_bar_widget.cpp b/Telegram/SourceFiles/history/view/history_view_top_bar_widget.cpp index 1c45f7b47..db0d1a65f 100644 --- a/Telegram/SourceFiles/history/view/history_view_top_bar_widget.cpp +++ b/Telegram/SourceFiles/history/view/history_view_top_bar_widget.cpp @@ -1018,7 +1018,7 @@ void TopBarWidget::updateOnlineDisplay() { const auto self = session().user(); auto online = 0; auto onlyMe = true; - for (const auto user : chat->participants) { + for (const auto &user : chat->participants) { if (user->onlineTill > now) { ++online; if (onlyMe && user != self) onlyMe = false; @@ -1095,7 +1095,7 @@ void TopBarWidget::updateOnlineDisplayTimer() { if (const auto user = peer->asUser()) { handleUser(user); } else if (const auto chat = peer->asChat()) { - for (const auto user : chat->participants) { + for (const auto &user : chat->participants) { handleUser(user); } } else if (peer->isChannel()) { diff --git a/Telegram/SourceFiles/history/view/media/history_view_poll.cpp b/Telegram/SourceFiles/history/view/media/history_view_poll.cpp index 365e7e0e8..4693b1e2f 100644 --- a/Telegram/SourceFiles/history/view/media/history_view_poll.cpp +++ b/Telegram/SourceFiles/history/view/media/history_view_poll.cpp @@ -752,7 +752,7 @@ void Poll::draw(Painter &p, const PaintContext &context) const { auto &&answers = ranges::views::zip( _answers, ranges::views::ints(0, int(_answers.size()))); - for (const auto &[answer, index] : answers) { + for (const auto [answer, index] : answers) { const auto animation = _answersAnimation ? &_answersAnimation->data[index] : nullptr; diff --git a/Telegram/SourceFiles/history/view/media/history_view_web_page.cpp b/Telegram/SourceFiles/history/view/media/history_view_web_page.cpp index 2d1a35cf9..9ce06e162 100644 --- a/Telegram/SourceFiles/history/view/media/history_view_web_page.cpp +++ b/Telegram/SourceFiles/history/view/media/history_view_web_page.cpp @@ -56,7 +56,7 @@ std::vector> PrepareCollageMedia( const WebPageCollage &data) { auto result = std::vector>(); result.reserve(data.items.size()); - for (const auto item : data.items) { + for (const auto &item : data.items) { if (const auto document = std::get_if(&item)) { result.push_back(std::make_unique( parent, diff --git a/Telegram/SourceFiles/info/profile/info_profile_values.cpp b/Telegram/SourceFiles/info/profile/info_profile_values.cpp index 773869a64..862e58782 100644 --- a/Telegram/SourceFiles/info/profile/info_profile_values.cpp +++ b/Telegram/SourceFiles/info/profile/info_profile_values.cpp @@ -266,7 +266,7 @@ rpl::producer AdminsCountValue(not_null peer) { rpl::producer RestrictionsCountValue(not_null peer) { const auto countOfRestrictions = [](ChatRestrictions restrictions) { auto count = 0; - for (const auto f : Data::ListOfRestrictions()) { + for (const auto &f : Data::ListOfRestrictions()) { if (restrictions & f) count++; } return int(Data::ListOfRestrictions().size()) - count; diff --git a/Telegram/SourceFiles/lang/lang_tag.cpp b/Telegram/SourceFiles/lang/lang_tag.cpp index 0cf5475cb..3ad0309c8 100644 --- a/Telegram/SourceFiles/lang/lang_tag.cpp +++ b/Telegram/SourceFiles/lang/lang_tag.cpp @@ -903,7 +903,7 @@ QString FormatDouble(float64 value) { int NonZeroPartToInt(QString value) { auto zeros = 0; - for (const auto ch : value) { + for (const auto &ch : value) { if (ch == '0') { ++zeros; } else { @@ -988,7 +988,7 @@ void UpdatePluralRules(const QString &languageId) { static auto kMap = GeneratePluralRulesMap(); auto parent = uint64(0); auto key = uint64(0); - for (const auto ch : languageId) { + for (const auto &ch : languageId) { const auto converted = ConvertKeyChar(ch.unicode()); if (converted == '-' && !parent) { parent = key; diff --git a/Telegram/SourceFiles/main/main_session_settings.cpp b/Telegram/SourceFiles/main/main_session_settings.cpp index 2db310386..d8caa3e60 100644 --- a/Telegram/SourceFiles/main/main_session_settings.cpp +++ b/Telegram/SourceFiles/main/main_session_settings.cpp @@ -48,7 +48,7 @@ QByteArray SessionSettings::serialize() const { stream << qint32(kVersionTag) << qint32(kVersion); stream << static_cast(_selectorTab); stream << qint32(_groupStickersSectionHidden.size()); - for (const auto peerId : _groupStickersSectionHidden) { + for (const auto &peerId : _groupStickersSectionHidden) { stream << SerializePeerId(peerId); } stream << qint32(_supportSwitch); diff --git a/Telegram/SourceFiles/mainwidget.cpp b/Telegram/SourceFiles/mainwidget.cpp index 3d26b8ee2..2205b98ff 100644 --- a/Telegram/SourceFiles/mainwidget.cpp +++ b/Telegram/SourceFiles/mainwidget.cpp @@ -818,7 +818,7 @@ void MainWidget::handleAudioUpdate(const Media::Player::TrackState &state) { if (document) { if (const auto items = InlineBots::Layout::documentItems()) { if (const auto i = items->find(document); i != items->end()) { - for (const auto item : i->second) { + for (const auto &item : i->second) { item->update(); } } diff --git a/Telegram/SourceFiles/media/view/media_view_overlay_raster.cpp b/Telegram/SourceFiles/media/view/media_view_overlay_raster.cpp index 7f60b9a60..dc21b43f4 100644 --- a/Telegram/SourceFiles/media/view/media_view_overlay_raster.cpp +++ b/Telegram/SourceFiles/media/view/media_view_overlay_raster.cpp @@ -38,7 +38,7 @@ void OverlayWidget::RendererSW::paintBackground() { const auto &bg = _owner->_fullScreenVideo ? st::mediaviewVideoBg : st::mediaviewBg; - for (const auto rect : region) { + for (const auto &rect : region) { _p->fillRect(rect, bg); } _p->setCompositionMode(m); diff --git a/Telegram/SourceFiles/passport/passport_encryption.cpp b/Telegram/SourceFiles/passport/passport_encryption.cpp index 3e3d4684f..3dec6d4e8 100644 --- a/Telegram/SourceFiles/passport/passport_encryption.cpp +++ b/Telegram/SourceFiles/passport/passport_encryption.cpp @@ -268,7 +268,7 @@ std::vector DeserializeErrors(bytes::const_span json) { } auto array = document.array(); auto result = std::vector(); - for (const auto &error : array) { + for (const auto error : array) { if (!error.isObject()) { LOG(("API Error: Not an object inside errors JSON.")); continue; diff --git a/Telegram/SourceFiles/passport/passport_form_controller.cpp b/Telegram/SourceFiles/passport/passport_form_controller.cpp index 09d0bd574..b248d63d4 100644 --- a/Telegram/SourceFiles/passport/passport_form_controller.cpp +++ b/Telegram/SourceFiles/passport/passport_form_controller.cpp @@ -2544,7 +2544,7 @@ bool FormController::parseForm(const MTPaccount_AuthorizationForm &result) { } for (const auto &required : data.vrequired_types().v) { const auto row = CollectRequestedRow(required); - for (const auto requested : row.values) { + for (const auto &requested : row.values) { const auto type = requested.type; const auto [i, ok] = _form.values.emplace(type, Value(type)); auto &value = i->second; diff --git a/Telegram/SourceFiles/payments/ui/payments_form_summary.cpp b/Telegram/SourceFiles/payments/ui/payments_form_summary.cpp index 310a3b08d..b98d2e068 100644 --- a/Telegram/SourceFiles/payments/ui/payments_form_summary.cpp +++ b/Telegram/SourceFiles/payments/ui/payments_form_summary.cpp @@ -458,7 +458,7 @@ void FormSummary::setupSuggestedTips(not_null layout) { } height += buttons[0].widget->height() + skip; }; - for (const auto button : buttons) { + for (const auto &button : buttons) { if (button.minWidth <= left) { left -= button.minWidth + skip; ++rowEnd; diff --git a/Telegram/SourceFiles/platform/mac/touchbar/items/mac_scrubber_item.mm b/Telegram/SourceFiles/platform/mac/touchbar/items/mac_scrubber_item.mm index b47227a93..ad4e166f2 100644 --- a/Telegram/SourceFiles/platform/mac/touchbar/items/mac_scrubber_item.mm +++ b/Telegram/SourceFiles/platform/mac/touchbar/items/mac_scrubber_item.mm @@ -237,7 +237,7 @@ void AppendRecentStickers( to.emplace_back(PickerScrubberItem(document)); } } - for (const auto recent : recentPack) { + for (const auto &recent : recentPack) { to.emplace_back(PickerScrubberItem(recent.first)); } } diff --git a/Telegram/SourceFiles/profile/profile_block_group_members.cpp b/Telegram/SourceFiles/profile/profile_block_group_members.cpp index 90257866d..4f3f0be1f 100644 --- a/Telegram/SourceFiles/profile/profile_block_group_members.cpp +++ b/Telegram/SourceFiles/profile/profile_block_group_members.cpp @@ -281,7 +281,7 @@ void GroupMembersWidget::fillChatMembers(not_null chat) { reserveItemsForSize(chat->participants.size()); addUser(chat, chat->session().user())->onlineForSort = std::numeric_limits::max(); - for (const auto user : chat->participants) { + for (const auto &user : chat->participants) { if (!user->isSelf()) { addUser(chat, user); } diff --git a/Telegram/SourceFiles/support/support_templates.cpp b/Telegram/SourceFiles/support/support_templates.cpp index bb2512605..6d528a505 100644 --- a/Telegram/SourceFiles/support/support_templates.cpp +++ b/Telegram/SourceFiles/support/support_templates.cpp @@ -41,7 +41,7 @@ bool IsTemplatesFile(const QString &file) { QString NormalizeQuestion(const QString &question) { auto result = QString(); result.reserve(question.size()); - for (const auto ch : question) { + for (const auto &ch : question) { if (ch.isLetterOrNumber()) { result.append(ch.toLower()); } diff --git a/Telegram/SourceFiles/ui/boxes/country_select_box.cpp b/Telegram/SourceFiles/ui/boxes/country_select_box.cpp index e122b50ee..89be48553 100644 --- a/Telegram/SourceFiles/ui/boxes/country_select_box.cpp +++ b/Telegram/SourceFiles/ui/boxes/country_select_box.cpp @@ -233,7 +233,7 @@ void CountrySelectBox::Inner::init() { } } auto index = 0; - for (const auto info : _list) { + for (const auto &info : _list) { auto full = info.country + ' ' + (!info.alternativeName.isEmpty() diff --git a/Telegram/SourceFiles/ui/boxes/single_choice_box.cpp b/Telegram/SourceFiles/ui/boxes/single_choice_box.cpp index 6b1ea3e5f..a68e1cfa4 100644 --- a/Telegram/SourceFiles/ui/boxes/single_choice_box.cpp +++ b/Telegram/SourceFiles/ui/boxes/single_choice_box.cpp @@ -29,7 +29,7 @@ void SingleChoiceBox( layout, st::boxOptionListPadding.top() + st::autolockButton.margin.top())); auto &&ints = ranges::views::ints(0, ranges::unreachable); - for (const auto &[i, text] : ranges::views::zip(ints, args.options)) { + for (const auto [i, text] : ranges::views::zip(ints, args.options)) { layout->add( object_ptr( layout, diff --git a/Telegram/SourceFiles/window/themes/window_theme_editor_block.cpp b/Telegram/SourceFiles/window/themes/window_theme_editor_block.cpp index ec23105fe..08c1a7a68 100644 --- a/Telegram/SourceFiles/window/themes/window_theme_editor_block.cpp +++ b/Telegram/SourceFiles/window/themes/window_theme_editor_block.cpp @@ -257,7 +257,7 @@ void EditorBlock::addToSearch(const Row &row) { if (!query.isEmpty()) resetSearch(); auto index = findRowIndex(&row); - for (const auto ch : row.searchStartChars()) { + for (const auto &ch : row.searchStartChars()) { _searchIndex[ch].insert(index); } @@ -269,7 +269,7 @@ void EditorBlock::removeFromSearch(const Row &row) { if (!query.isEmpty()) resetSearch(); auto index = findRowIndex(&row); - for (const auto ch : row.searchStartChars()) { + for (const auto &ch : row.searchStartChars()) { const auto i = _searchIndex.find(ch); if (i != end(_searchIndex)) { i->second.remove(index);