From b6df430aa82e0791fa669f7ec3379ba4d8db6279 Mon Sep 17 00:00:00 2001 From: Evgenii Zheltonozhskii Date: Thu, 14 Jun 2018 12:28:48 +0300 Subject: [PATCH] Get rid of OrderedSet --- Telegram/SourceFiles/apiwrap.cpp | 12 +- Telegram/SourceFiles/apiwrap.h | 2 +- Telegram/SourceFiles/app.cpp | 26 +- Telegram/SourceFiles/app.h | 2 +- Telegram/SourceFiles/auth_session.cpp | 2 +- Telegram/SourceFiles/auth_session.h | 6 +- Telegram/SourceFiles/base/observer.cpp | 8 +- Telegram/SourceFiles/base/ordered_set.h | 285 ------------------ Telegram/SourceFiles/boxes/peer_list_box.cpp | 2 +- Telegram/SourceFiles/boxes/peer_list_box.h | 6 +- .../boxes/peer_list_controllers.cpp | 2 +- Telegram/SourceFiles/boxes/share_box.cpp | 2 +- Telegram/SourceFiles/boxes/share_box.h | 2 +- .../chat_helpers/field_autocomplete.cpp | 2 +- .../SourceFiles/chat_helpers/stickers.cpp | 8 +- Telegram/SourceFiles/chat_helpers/stickers.h | 2 +- .../chat_helpers/stickers_list_widget.cpp | 4 +- .../chat_helpers/stickers_list_widget.h | 2 +- Telegram/SourceFiles/core/basic_types.h | 1 - .../data/data_abstract_structure.cpp | 3 +- .../dialogs/dialogs_indexed_list.cpp | 2 +- Telegram/SourceFiles/facades.h | 2 +- Telegram/SourceFiles/history/history.cpp | 23 +- Telegram/SourceFiles/history/history.h | 8 +- Telegram/SourceFiles/history/history_item.cpp | 2 +- .../SourceFiles/history/history_message.cpp | 4 +- .../inline_bots/inline_bot_layout_item.cpp | 2 +- .../inline_bots/inline_bot_layout_item.h | 2 +- Telegram/SourceFiles/lang/lang_instance.cpp | 4 +- Telegram/SourceFiles/mainwidget.cpp | 4 +- Telegram/SourceFiles/mainwidget.h | 4 +- Telegram/SourceFiles/mediaview.cpp | 25 +- Telegram/SourceFiles/overviewwidget.cpp | 12 +- .../platform/linux/specific_linux.cpp | 4 +- .../profile/profile_block_group_members.cpp | 10 +- .../profile/profile_channel_controllers.cpp | 2 +- .../SourceFiles/storage/file_download.cpp | 8 +- Telegram/SourceFiles/storage/file_download.h | 2 +- Telegram/SourceFiles/storage/localstorage.cpp | 14 +- Telegram/SourceFiles/structs.cpp | 8 +- Telegram/SourceFiles/structs.h | 14 +- Telegram/SourceFiles/ui/animation.cpp | 18 +- Telegram/SourceFiles/ui/animation.h | 2 +- .../SourceFiles/ui/style/style_core_icon.cpp | 2 +- Telegram/SourceFiles/ui/toast/toast_manager.h | 2 +- .../window/themes/window_theme_editor.cpp | 4 +- .../themes/window_theme_editor_block.cpp | 20 +- .../window/themes/window_theme_editor_block.h | 2 +- 48 files changed, 150 insertions(+), 435 deletions(-) delete mode 100644 Telegram/SourceFiles/base/ordered_set.h diff --git a/Telegram/SourceFiles/apiwrap.cpp b/Telegram/SourceFiles/apiwrap.cpp index a6a9c8ac3..9fc1f84c8 100644 --- a/Telegram/SourceFiles/apiwrap.cpp +++ b/Telegram/SourceFiles/apiwrap.cpp @@ -983,7 +983,7 @@ void ApiWrap::saveStickerSets(const Stickers::Order &localOrder, const Stickers: if (writeFaved) Local::writeFavedStickers(); Auth().data().stickersUpdated().notify(true); - if (_stickerSetDisenableRequests.isEmpty()) { + if (_stickerSetDisenableRequests.empty()) { stickersSaveOrder(); } else { requestSendDelayed(); @@ -991,8 +991,8 @@ void ApiWrap::saveStickerSets(const Stickers::Order &localOrder, const Stickers: } void ApiWrap::stickerSetDisenabled(mtpRequestId requestId) { - _stickerSetDisenableRequests.remove(requestId); - if (_stickerSetDisenableRequests.isEmpty()) { + _stickerSetDisenableRequests.erase(requestId); + if (_stickerSetDisenableRequests.empty()) { stickersSaveOrder(); } }; @@ -1396,7 +1396,7 @@ void ApiWrap::resolveWebPages() { if (i.value() > 0) continue; if (i.key()->pendingTill <= t) { auto j = items.constFind(i.key()); - if (j != items.cend() && !j.value().isEmpty()) { + if (j != items.cend() && !j.value().empty()) { for_const (auto item, j.value()) { if (item->id > 0) { if (item->channelId() == NoChannel) { @@ -2001,7 +2001,7 @@ void ApiWrap::sendSaveChatAdminsRequests(not_null chat) { chat->admins.insert(user); } } else { - chat->admins.remove(user); + chat->admins.erase(user); } } }) @@ -2031,7 +2031,7 @@ void ApiWrap::sendSaveChatAdminsRequests(not_null chat) { if (!admins->empty()) { toAppoint.reserve(admins->size()); for (auto user : *admins) { - if (!toRemove.remove(user) && user->id != peerFromUser(chat->creator)) { + if (!toRemove.erase(user) && user->id != peerFromUser(chat->creator)) { toAppoint.push_back(user); } } diff --git a/Telegram/SourceFiles/apiwrap.h b/Telegram/SourceFiles/apiwrap.h index 8050d69d4..ad5b8033f 100644 --- a/Telegram/SourceFiles/apiwrap.h +++ b/Telegram/SourceFiles/apiwrap.h @@ -192,7 +192,7 @@ private: QMap _draftsSaveRequestIds; base::Timer _draftsSaveTimer; - OrderedSet _stickerSetDisenableRequests; + std::set _stickerSetDisenableRequests; Stickers::Order _stickersOrder; mtpRequestId _stickersReorderRequestId = 0; mtpRequestId _stickersClearRecentRequestId = 0; diff --git a/Telegram/SourceFiles/app.cpp b/Telegram/SourceFiles/app.cpp index c4801e018..db67d7d10 100644 --- a/Telegram/SourceFiles/app.cpp +++ b/Telegram/SourceFiles/app.cpp @@ -85,7 +85,7 @@ GameItems gameItems; SharedContactItems sharedContactItems; GifItems gifItems; -using DependentItemsSet = OrderedSet; +using DependentItemsSet = std::set; using DependentItems = QMap; DependentItems dependentItems; @@ -897,7 +897,7 @@ void feedParticipantAdd(const MTPDupdateChatParticipantAdd &d) { if (d.vinviter_id.v == Auth().userId()) { chat->invitedByMe.insert(user); } else { - chat->invitedByMe.remove(user); + chat->invitedByMe.erase(user); } chat->count++; if (user->botInfo) { @@ -935,8 +935,8 @@ void feedParticipantDelete(const MTPDupdateChatParticipantDelete &d) { if (i != chat->participants.end()) { chat->participants.erase(i); chat->count--; - chat->invitedByMe.remove(user); - chat->admins.remove(user); + chat->invitedByMe.erase(user); + chat->admins.erase(user); if (user->isSelf()) { chat->flags &= ~MTPDchat::Flag::f_admin; } @@ -1016,7 +1016,7 @@ void feedParticipantAdmin(const MTPDupdateChatParticipantAdmin &d) { if (user->isSelf()) { chat->flags &= ~MTPDchat::Flag::f_admin; } - chat->admins.remove(user); + chat->admins.erase(user); } } else { chat->invalidateParticipants(); @@ -2151,8 +2151,8 @@ void historyRegDependency(HistoryItem *dependent, HistoryItem *dependency) { void historyUnregDependency(HistoryItem *dependent, HistoryItem *dependency) { auto i = ::dependentItems.find(dependency); if (i != ::dependentItems.cend()) { - i.value().remove(dependent); - if (i.value().isEmpty()) { + i.value().erase(dependent); + if (i.value().empty()) { ::dependentItems.erase(i); } } @@ -2578,7 +2578,7 @@ void regPhotoItem(PhotoData *data, HistoryItem *item) { } void unregPhotoItem(PhotoData *data, HistoryItem *item) { - ::photoItems[data].remove(item); + ::photoItems[data].erase(item); } const PhotoItems &photoItems() { @@ -2594,7 +2594,7 @@ void regDocumentItem(DocumentData *data, HistoryItem *item) { } void unregDocumentItem(DocumentData *data, HistoryItem *item) { - ::documentItems[data].remove(item); + ::documentItems[data].erase(item); } const DocumentItems &documentItems() { @@ -2610,7 +2610,7 @@ void regWebPageItem(WebPageData *data, HistoryItem *item) { } void unregWebPageItem(WebPageData *data, HistoryItem *item) { - ::webPageItems[data].remove(item); + ::webPageItems[data].erase(item); } const WebPageItems &webPageItems() { @@ -2622,7 +2622,7 @@ void regGameItem(GameData *data, HistoryItem *item) { } void unregGameItem(GameData *data, HistoryItem *item) { - ::gameItems[data].remove(item); + ::gameItems[data].erase(item); } const GameItems &gameItems() { @@ -2641,7 +2641,7 @@ void regSharedContactItem(qint32 userId, HistoryItem *item) { void unregSharedContactItem(qint32 userId, HistoryItem *item) { auto user = App::userLoaded(userId); auto canShareThisContact = user ? user->canShareThisContact() : false; - ::sharedContactItems[userId].remove(item); + ::sharedContactItems[userId].erase(item); if (canShareThisContact != (user ? user->canShareThisContact() : false)) { Notify::peerUpdatedDelayed(user, Notify::PeerUpdate::Flag::UserCanShareContact); } @@ -2674,7 +2674,7 @@ void stopGifItems() { QString phoneFromSharedContact(qint32 userId) { auto i = ::sharedContactItems.constFind(userId); - if (i != ::sharedContactItems.cend() && !i->isEmpty()) { + if (i != ::sharedContactItems.cend() && !i->empty()) { if (auto media = (*i->cbegin())->getMedia()) { if (media->type() == MediaTypeContact) { return static_cast(media)->phone(); diff --git a/Telegram/SourceFiles/app.h b/Telegram/SourceFiles/app.h index 86b042575..c45307e4b 100644 --- a/Telegram/SourceFiles/app.h +++ b/Telegram/SourceFiles/app.h @@ -34,7 +34,7 @@ class Messenger; class MainWindow; class MainWidget; -using HistoryItemsMap = OrderedSet; +using HistoryItemsMap = std::set; using PhotoItems = QHash; using DocumentItems = QHash; using WebPageItems = QHash; diff --git a/Telegram/SourceFiles/auth_session.cpp b/Telegram/SourceFiles/auth_session.cpp index b5b11b410..b0b832c8b 100644 --- a/Telegram/SourceFiles/auth_session.cpp +++ b/Telegram/SourceFiles/auth_session.cpp @@ -89,7 +89,7 @@ void AuthSessionData::constructFromSerialized(const QByteArray &serialized) { qint32 floatPlayerColumn = static_cast(Window::Column::Second); qint32 floatPlayerCorner = static_cast(RectPart::TopRight); QMap soundOverrides; - OrderedSet groupStickersSectionHidden; + std::set groupStickersSectionHidden; stream >> selectorTab; stream >> lastSeenWarningSeen; if (!stream.atEnd()) { diff --git a/Telegram/SourceFiles/auth_session.h b/Telegram/SourceFiles/auth_session.h index 0a47ef8b3..94e8f27d9 100644 --- a/Telegram/SourceFiles/auth_session.h +++ b/Telegram/SourceFiles/auth_session.h @@ -140,10 +140,10 @@ public: _variables.groupStickersSectionHidden.insert(peerId); } bool isGroupStickersSectionHidden(PeerId peerId) const { - return _variables.groupStickersSectionHidden.contains(peerId); + return _variables.groupStickersSectionHidden.find(peerId) != _variables.groupStickersSectionHidden.end(); } void removeGroupStickersSectionHidden(PeerId peerId) { - _variables.groupStickersSectionHidden.remove(peerId); + _variables.groupStickersSectionHidden.erase(peerId); } private: @@ -157,7 +157,7 @@ private: QMap soundOverrides; Window::Column floatPlayerColumn; RectPart floatPlayerCorner; - OrderedSet groupStickersSectionHidden; + std::set groupStickersSectionHidden; }; base::Variable _contactsLoaded = {false}; diff --git a/Telegram/SourceFiles/base/observer.cpp b/Telegram/SourceFiles/base/observer.cpp index 9705713b5..87d362e66 100644 --- a/Telegram/SourceFiles/base/observer.cpp +++ b/Telegram/SourceFiles/base/observer.cpp @@ -31,7 +31,7 @@ struct ObservableListWrap { ~ObservableListWrap() { CantUseObservables = true; } - OrderedSet list; + std::set list; }; ObservableListWrap &PendingObservables() { @@ -54,13 +54,13 @@ void RegisterPendingObservable(ObservableCallHandlers *handlers) { void UnregisterActiveObservable(ObservableCallHandlers *handlers) { if (CantUseObservables) return; - ActiveObservables().list.remove(handlers); + ActiveObservables().list.erase(handlers); } void UnregisterObservable(ObservableCallHandlers *handlers) { if (CantUseObservables) return; - PendingObservables().list.remove(handlers); - ActiveObservables().list.remove(handlers); + PendingObservables().list.erase(handlers); + ActiveObservables().list.erase(handlers); } } // namespace internal diff --git a/Telegram/SourceFiles/base/ordered_set.h b/Telegram/SourceFiles/base/ordered_set.h deleted file mode 100644 index a643d916c..000000000 --- a/Telegram/SourceFiles/base/ordered_set.h +++ /dev/null @@ -1,285 +0,0 @@ -/* -This file is part of Telegram Desktop, -the official desktop version of Telegram messaging app, see https://telegram.org - -Telegram Desktop is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -It is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -In addition, as a special exception, the copyright holders give permission -to link the code of portions of this program with the OpenSSL library. - -Full license: https://github.com/telegramdesktop/tdesktop/blob/master/LICENSE -Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org -*/ -#pragma once - -#include - -// ordered set template based on QMap -template class OrderedSet { - struct NullType {}; - using Self = OrderedSet; - using Impl = QMap; - using IteratorImpl = typename Impl::iterator; - using ConstIteratorImpl = typename Impl::const_iterator; - Impl impl_; - -public: - OrderedSet() = default; - OrderedSet(const OrderedSet &other) = default; - OrderedSet(OrderedSet &&other) = default; - OrderedSet &operator=(const OrderedSet &other) = default; - OrderedSet &operator=(OrderedSet &&other) = default; - ~OrderedSet() = default; - - inline bool operator==(const Self &other) const { - return impl_ == other.impl_; - } - inline bool operator!=(const Self &other) const { - return impl_ != other.impl_; - } - inline int size() const { - return impl_.size(); - } - inline bool isEmpty() const { - return impl_.isEmpty(); - } - inline void detach() { - return impl_.detach(); - } - inline bool isDetached() const { - return impl_.isDetached(); - } - inline void clear() { - return impl_.clear(); - } - inline QList values() const { - return impl_.keys(); - } - inline const T &first() const { - return impl_.firstKey(); - } - inline const T &last() const { - return impl_.lastKey(); - } - - class const_iterator; - class iterator { - public: - typedef typename IteratorImpl::iterator_category iterator_category; - typedef typename IteratorImpl::difference_type difference_type; - typedef T value_type; - typedef T *pointer; - typedef T &reference; - - iterator() = default; - iterator(const iterator &other) = default; - iterator &operator=(const iterator &other) = default; - inline const T &operator*() const { - return impl_.key(); - } - inline const T *operator->() const { - return &impl_.key(); - } - inline bool operator==(const iterator &other) const { - return impl_ == other.impl_; - } - inline bool operator!=(const iterator &other) const { - return impl_ != other.impl_; - } - inline iterator &operator++() { - ++impl_; - return *this; - } - inline iterator operator++(int) { - return iterator(impl_++); - } - inline iterator &operator--() { - --impl_; - return *this; - } - inline iterator operator--(int) { - return iterator(impl_--); - } - inline iterator operator+(int j) const { - return iterator(impl_ + j); - } - inline iterator operator-(int j) const { - return iterator(impl_ - j); - } - inline iterator &operator+=(int j) { - impl_ += j; - return *this; - } - inline iterator &operator-=(int j) { - impl_ -= j; - return *this; - } - - friend class const_iterator; - inline bool operator==(const const_iterator &other) const { - return impl_ == other.impl_; - } - inline bool operator!=(const const_iterator &other) const { - return impl_ != other.impl_; - } - - private: - explicit iterator(const IteratorImpl &impl) - : impl_(impl) {} - IteratorImpl impl_; - friend class OrderedSet; - }; - friend class iterator; - - class const_iterator { - public: - typedef typename IteratorImpl::iterator_category iterator_category; - typedef typename IteratorImpl::difference_type difference_type; - typedef T value_type; - typedef T *pointer; - typedef T &reference; - - const_iterator() = default; - const_iterator(const const_iterator &other) = default; - const_iterator &operator=(const const_iterator &other) = default; - const_iterator(const iterator &other) - : impl_(other.impl_) {} - const_iterator &operator=(const iterator &other) { - impl_ = other.impl_; - return *this; - } - inline const T &operator*() const { - return impl_.key(); - } - inline const T *operator->() const { - return &impl_.key(); - } - inline bool operator==(const const_iterator &other) const { - return impl_ == other.impl_; - } - inline bool operator!=(const const_iterator &other) const { - return impl_ != other.impl_; - } - inline const_iterator &operator++() { - ++impl_; - return *this; - } - inline const_iterator operator++(int) { - return const_iterator(impl_++); - } - inline const_iterator &operator--() { - --impl_; - return *this; - } - inline const_iterator operator--(int) { - return const_iterator(impl_--); - } - inline const_iterator operator+(int j) const { - return const_iterator(impl_ + j); - } - inline const_iterator operator-(int j) const { - return const_iterator(impl_ - j); - } - inline const_iterator &operator+=(int j) { - impl_ += j; - return *this; - } - inline const_iterator &operator-=(int j) { - impl_ -= j; - return *this; - } - - friend class iterator; - inline bool operator==(const iterator &other) const { - return impl_ == other.impl_; - } - inline bool operator!=(const iterator &other) const { - return impl_ != other.impl_; - } - - private: - explicit const_iterator(const ConstIteratorImpl &impl) - : impl_(impl) {} - ConstIteratorImpl impl_; - friend class OrderedSet; - }; - friend class const_iterator; - - // STL style - inline iterator begin() { - return iterator(impl_.begin()); - } - inline const_iterator begin() const { - return const_iterator(impl_.cbegin()); - } - inline const_iterator constBegin() const { - return const_iterator(impl_.cbegin()); - } - inline const_iterator cbegin() const { - return const_iterator(impl_.cbegin()); - } - inline iterator end() { - detach(); - return iterator(impl_.end()); - } - inline const_iterator end() const { - return const_iterator(impl_.cend()); - } - inline const_iterator constEnd() const { - return const_iterator(impl_.cend()); - } - inline const_iterator cend() const { - return const_iterator(impl_.cend()); - } - inline iterator erase(iterator it) { - return iterator(impl_.erase(it.impl_)); - } - - inline iterator insert(const T &value) { - return iterator(impl_.insert(value, NullType())); - } - inline iterator insert(const_iterator pos, const T &value) { - return iterator(impl_.insert(pos.impl_, value, NullType())); - } - inline int remove(const T &value) { - return impl_.remove(value); - } - inline bool contains(const T &value) const { - return impl_.contains(value); - } - - // more Qt - typedef iterator Iterator; - typedef const_iterator ConstIterator; - inline int count() const { - return impl_.count(); - } - inline iterator find(const T &value) { - return iterator(impl_.find(value)); - } - inline const_iterator find(const T &value) const { - return const_iterator(impl_.constFind(value)); - } - inline const_iterator constFind(const T &value) const { - return const_iterator(impl_.constFind(value)); - } - inline Self &unite(const Self &other) { - impl_.unite(other.impl_); - return *this; - } - - // STL compatibility - typedef typename Impl::difference_type difference_type; - typedef typename Impl::size_type size_type; - inline bool empty() const { - return impl_.empty(); - } -}; diff --git a/Telegram/SourceFiles/boxes/peer_list_box.cpp b/Telegram/SourceFiles/boxes/peer_list_box.cpp index df45501bd..8f980db97 100644 --- a/Telegram/SourceFiles/boxes/peer_list_box.cpp +++ b/Telegram/SourceFiles/boxes/peer_list_box.cpp @@ -620,7 +620,7 @@ void PeerListBox::Inner::removeFromSearchIndex(not_null row) { } } } - row->setNameFirstChars(OrderedSet()); + row->setNameFirstChars(std::set()); } } diff --git a/Telegram/SourceFiles/boxes/peer_list_box.h b/Telegram/SourceFiles/boxes/peer_list_box.h index e2c60bc12..d2664bf70 100644 --- a/Telegram/SourceFiles/boxes/peer_list_box.h +++ b/Telegram/SourceFiles/boxes/peer_list_box.h @@ -135,10 +135,10 @@ public: void paintUserpic(Painter &p, TimeMs ms, int x, int y, int outerWidth); double checkedRatio(); - void setNameFirstChars(const OrderedSet &nameFirstChars) { + void setNameFirstChars(const std::set &nameFirstChars) { _nameFirstChars = nameFirstChars; } - const OrderedSet &nameFirstChars() const { + const std::set &nameFirstChars() const { return _nameFirstChars; } @@ -163,7 +163,7 @@ private: Text _name; Text _status; StatusType _statusType = StatusType::Online; - OrderedSet _nameFirstChars; + std::set _nameFirstChars; int _absoluteIndex = -1; State _disabledState = State::Active; bool _initialized : 1; diff --git a/Telegram/SourceFiles/boxes/peer_list_controllers.cpp b/Telegram/SourceFiles/boxes/peer_list_controllers.cpp index c1607f4a8..f5aa2b15f 100644 --- a/Telegram/SourceFiles/boxes/peer_list_controllers.cpp +++ b/Telegram/SourceFiles/boxes/peer_list_controllers.cpp @@ -600,7 +600,7 @@ void EditChatAdminsBoxController::rebuildRows() { for (auto i = _chat->participants.cbegin(), e = _chat->participants.cend(); i != e; ++i) { if (i.key()->id == peerFromUser(_chat->creator)) continue; - if (_chat->admins.contains(i.key())) { + if (_chat->admins.find(i.key()) != _chat->admins.end()) { admins.push_back(i.key()); } else { others.push_back(i.key()); diff --git a/Telegram/SourceFiles/boxes/share_box.cpp b/Telegram/SourceFiles/boxes/share_box.cpp index d7be573f7..0b1f3cccc 100644 --- a/Telegram/SourceFiles/boxes/share_box.cpp +++ b/Telegram/SourceFiles/boxes/share_box.cpp @@ -661,7 +661,7 @@ void ShareBox::Inner::changePeerCheckState(Chat *chat, bool checked, ChangeState _selected.insert(chat->peer); setActive(chatIndex(chat->peer)); } else { - _selected.remove(chat->peer); + _selected.erase(chat->peer); } if (useCallback != ChangeStateWay::SkipCallback && _peerSelectedChangedCallback) { _peerSelectedChangedCallback(chat->peer, checked); diff --git a/Telegram/SourceFiles/boxes/share_box.h b/Telegram/SourceFiles/boxes/share_box.h index b9d484cb7..5a82afaac 100644 --- a/Telegram/SourceFiles/boxes/share_box.h +++ b/Telegram/SourceFiles/boxes/share_box.h @@ -199,7 +199,7 @@ private: using DataMap = QMap; DataMap _dataMap; - using SelectedChats = OrderedSet; + using SelectedChats = std::set; SelectedChats _selected; base::lambda _peerSelectedChangedCallback; diff --git a/Telegram/SourceFiles/chat_helpers/field_autocomplete.cpp b/Telegram/SourceFiles/chat_helpers/field_autocomplete.cpp index 9e4e0cb5c..68eba5f3b 100644 --- a/Telegram/SourceFiles/chat_helpers/field_autocomplete.cpp +++ b/Telegram/SourceFiles/chat_helpers/field_autocomplete.cpp @@ -277,7 +277,7 @@ void FieldAutocomplete::updateFiltered(bool resetScroll) { cnt = _user->botInfo->commands.size(); bots.insert(_user, true); } else if (_channel && _channel->isMegagroup()) { - if (_channel->mgInfo->bots.isEmpty()) { + if (_channel->mgInfo->bots.empty()) { if (!_channel->mgInfo->botStatus) { Auth().api().requestBots(_channel); } diff --git a/Telegram/SourceFiles/chat_helpers/stickers.cpp b/Telegram/SourceFiles/chat_helpers/stickers.cpp index 16b005cb0..a88fe5baf 100644 --- a/Telegram/SourceFiles/chat_helpers/stickers.cpp +++ b/Telegram/SourceFiles/chat_helpers/stickers.cpp @@ -514,7 +514,7 @@ void SpecialSetReceived(quint64 setId, const QString &setTitle, const QVector &data, const QVector &unread, qint32 hash) { - OrderedSet unreadMap; + std::set unreadMap; for_const (auto &unreadSetId, unread) { unreadMap.insert(unreadSetId.v); } auto &setsOrder = Global::RefFeaturedStickerSetsOrder(); @@ -548,7 +548,7 @@ void FeaturedSetsReceived(const QVector &data, const QVect auto title = GetSetTitle(*set); if (it == sets.cend()) { auto setClientFlags = MTPDstickerSet_ClientFlag::f_featured | MTPDstickerSet_ClientFlag::f_not_loaded; - if (unreadMap.contains(set->vid.v)) { + if (unreadMap.find(set->vid.v) != unreadMap.end()) { setClientFlags |= MTPDstickerSet_ClientFlag::f_unread; } it = sets.insert(set->vid.v, Set(set->vid.v, set->vaccess_hash.v, title, qs(set->vshort_name), @@ -562,7 +562,7 @@ void FeaturedSetsReceived(const QVector &data, const QVect MTPDstickerSet_ClientFlag::f_not_loaded | MTPDstickerSet_ClientFlag::f_special); it->flags = set->vflags.v | clientFlags; it->flags |= MTPDstickerSet_ClientFlag::f_featured; - if (unreadMap.contains(it->id)) { + if (unreadMap.find(it->id) != unreadMap.end()) { it->flags |= MTPDstickerSet_ClientFlag::f_unread; } else { it->flags &= ~MTPDstickerSet_ClientFlag::f_unread; @@ -859,7 +859,7 @@ FeaturedReader::FeaturedReader(QObject *parent) } void FeaturedReader::scheduleRead(quint64 setId) { - if (!_setIds.contains(setId)) { + if (_setIds.find(setId) == _setIds.end()) { _setIds.insert(setId); _timer->start(kReadFeaturedSetsTimeoutMs); } diff --git a/Telegram/SourceFiles/chat_helpers/stickers.h b/Telegram/SourceFiles/chat_helpers/stickers.h index b5456f14e..97c8436ed 100644 --- a/Telegram/SourceFiles/chat_helpers/stickers.h +++ b/Telegram/SourceFiles/chat_helpers/stickers.h @@ -59,7 +59,7 @@ private: void readSets(); object_ptr _timer; - OrderedSet _setIds; + std::set _setIds; }; } // namespace internal diff --git a/Telegram/SourceFiles/chat_helpers/stickers_list_widget.cpp b/Telegram/SourceFiles/chat_helpers/stickers_list_widget.cpp index abcebf19d..880cd5029 100644 --- a/Telegram/SourceFiles/chat_helpers/stickers_list_widget.cpp +++ b/Telegram/SourceFiles/chat_helpers/stickers_list_widget.cpp @@ -600,7 +600,7 @@ void StickersListWidget::installedLocally(quint64 setId) { } void StickersListWidget::notInstalledLocally(quint64 setId) { - _installedLocallySets.remove(setId); + _installedLocallySets.erase(setId); } void StickersListWidget::clearInstalledLocally() { @@ -1249,7 +1249,7 @@ void StickersListWidget::appendSet(Sets &to, quint64 setId, AppendSkip skip) { if ((skip == AppendSkip::Archived) && (it->flags & MTPDstickerSet::Flag::f_archived)) return; if ((skip == AppendSkip::Installed) && (it->flags & MTPDstickerSet::Flag::f_installed) && !(it->flags & MTPDstickerSet::Flag::f_archived)) { - if (!_installedLocallySets.contains(setId)) { + if (_installedLocallySets.find(setId) == _installedLocallySets.end()) { return; } } diff --git a/Telegram/SourceFiles/chat_helpers/stickers_list_widget.h b/Telegram/SourceFiles/chat_helpers/stickers_list_widget.h index 8a70a8972..d4fa91371 100644 --- a/Telegram/SourceFiles/chat_helpers/stickers_list_widget.h +++ b/Telegram/SourceFiles/chat_helpers/stickers_list_widget.h @@ -219,7 +219,7 @@ private: ChannelData *_megagroupSet = nullptr; Sets _mySets; Sets _featuredSets; - OrderedSet _installedLocallySets; + std::set _installedLocallySets; QList _custom; base::flat_set> _favedStickersMap; diff --git a/Telegram/SourceFiles/core/basic_types.h b/Telegram/SourceFiles/core/basic_types.h index 85b06de38..58cef3778 100644 --- a/Telegram/SourceFiles/core/basic_types.h +++ b/Telegram/SourceFiles/core/basic_types.h @@ -21,7 +21,6 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org #pragma once #include "base/build_config.h" -#include "base/ordered_set.h" #include #include #include diff --git a/Telegram/SourceFiles/data/data_abstract_structure.cpp b/Telegram/SourceFiles/data/data_abstract_structure.cpp index a0662a5b1..b7ae98e13 100644 --- a/Telegram/SourceFiles/data/data_abstract_structure.cpp +++ b/Telegram/SourceFiles/data/data_abstract_structure.cpp @@ -19,13 +19,12 @@ Full license: https://github.com/telegramdesktop/tdesktop/blob/master/LICENSE Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org */ #include "data/data_abstract_structure.h" -#include "base/ordered_set.h" #include "core/utils.h" namespace Data { namespace { -using DataStructures = OrderedSet; +using DataStructures = std::set; NeverFreedPointer structures; } // namespace diff --git a/Telegram/SourceFiles/dialogs/dialogs_indexed_list.cpp b/Telegram/SourceFiles/dialogs/dialogs_indexed_list.cpp index e20b3de4a..603212ef9 100644 --- a/Telegram/SourceFiles/dialogs/dialogs_indexed_list.cpp +++ b/Telegram/SourceFiles/dialogs/dialogs_indexed_list.cpp @@ -139,7 +139,7 @@ void IndexedList::adjustByName(PeerData *peer, const PeerData::Names &oldNames, list->del(peer->id, mainRow); } } - if (!toAdd.isEmpty()) { + if (!toAdd.empty()) { for_const (auto ch, toAdd) { auto j = _index.find(ch); if (j == _index.cend()) { diff --git a/Telegram/SourceFiles/facades.h b/Telegram/SourceFiles/facades.h index f319e9f50..33948bf3b 100644 --- a/Telegram/SourceFiles/facades.h +++ b/Telegram/SourceFiles/facades.h @@ -324,7 +324,7 @@ DeclareRefVar(base::Observable, PhoneCallsEnabledChanged); typedef QMap HiddenPinnedMessagesMap; DeclareVar(HiddenPinnedMessagesMap, HiddenPinnedMessages); -typedef OrderedSet PendingItemsMap; +typedef std::set PendingItemsMap; DeclareRefVar(PendingItemsMap, PendingRepaintItems); DeclareVar(Stickers::Sets, StickerSets); diff --git a/Telegram/SourceFiles/history/history.cpp b/Telegram/SourceFiles/history/history.cpp index e3fe0cb0f..0c722cf1f 100644 --- a/Telegram/SourceFiles/history/history.cpp +++ b/Telegram/SourceFiles/history/history.cpp @@ -786,7 +786,7 @@ void Histories::setIsPinned(History *history, bool isPinned) { minIndexHistory->setPinnedDialog(false); } } else { - _pinnedDialogs.remove(history); + _pinnedDialogs.erase(history); } } @@ -1054,8 +1054,8 @@ HistoryItem *History::createItem(const MTPMessage &msg, bool applyServiceAction, } Notify::peerUpdatedDelayed(peer, Notify::PeerUpdate::Flag::AdminsChanged); } - megagroupInfo->bots.remove(user); - if (megagroupInfo->bots.isEmpty() && megagroupInfo->botStatus > 0) { + megagroupInfo->bots.erase(user); + if (megagroupInfo->bots.empty() && megagroupInfo->botStatus > 0) { megagroupInfo->botStatus = -1; } } @@ -1366,7 +1366,7 @@ HistoryItem *History::addNewItem(HistoryItem *adding, bool newMsg) { if (adding->definesReplyKeyboard()) { auto markupFlags = adding->replyKeyboardFlags(); if (!(markupFlags & MTPDreplyKeyboardMarkup::Flag::f_selective) || adding->mentionsMe()) { - auto getMarkupSenders = [this]() -> OrderedSet> * { + auto getMarkupSenders = [this]() -> std::set> * { if (auto chat = peer->asChat()) { return &chat->markupSenders; } else if (auto channel = peer->asMegagroup()) { @@ -1387,11 +1387,13 @@ HistoryItem *History::addNewItem(HistoryItem *adding, bool newMsg) { if (peer->isChat()) { botNotInChat = adding->from()->isUser() && (!peer->canWrite() || !peer->asChat()->participants.isEmpty()) && - !peer->asChat()->participants.contains(adding->from()->asUser()); + (peer->asChat()->participants.find(adding->from()->asUser()) == + peer->asChat()->participants.end()); } else if (peer->isMegagroup()) { botNotInChat = adding->from()->isUser() && (!peer->canWrite() || peer->asChannel()->mgInfo->botStatus != 0) && - !peer->asChannel()->mgInfo->bots.contains(adding->from()->asUser()); + (peer->asChannel()->mgInfo->bots.find(adding->from()->asUser()) == + peer->asChannel()->mgInfo->bots.end()); } if (botNotInChat) { clearLastKeyboard(); @@ -1525,7 +1527,7 @@ void History::addOlderSlice(const QVector &slice) { bool channel = isChannel(); qint32 mask = 0; QList> *lastAuthors = nullptr; - OrderedSet> *markupSenders = nullptr; + std::set> *markupSenders = nullptr; if (peer->isChat()) { lastAuthors = &peer->asChat()->lastAuthors; markupSenders = &peer->asChat()->markupSenders; @@ -1560,7 +1562,7 @@ void History::addOlderSlice(const QVector &slice) { if (!lastKeyboardInited && item->definesReplyKeyboard() && !item->out()) { auto markupFlags = item->replyKeyboardFlags(); if (!(markupFlags & MTPDreplyKeyboardMarkup::Flag::f_selective) || item->mentionsMe()) { - bool wasKeyboardHide = markupSenders->contains(item->author()); + bool wasKeyboardHide = markupSenders->find(item->author()) != markupSenders->end(); if (!wasKeyboardHide) { markupSenders->insert(item->author()); } @@ -1575,7 +1577,8 @@ void History::addOlderSlice(const QVector &slice) { botNotInChat = (!peer->canWrite() || peer->asChannel()->mgInfo->botStatus != 0) && item->author()->isUser() && - !peer->asChannel()->mgInfo->bots.contains(item->author()->asUser()); + (peer->asChannel()->mgInfo->bots.find(item->author()->asUser()) == + peer->asChannel()->mgInfo->bots.end()); } if (wasKeyboardHide || botNotInChat) { clearLastKeyboard(); @@ -2232,7 +2235,7 @@ void History::clear(bool leaveItems) { } if (!leaveItems) { for (auto i = 0; i != OverviewCount; ++i) { - if (!_overview[i].isEmpty()) { + if (!_overview[i].empty()) { _overviewCountData[i] = -1; // not loaded yet _overview[i].clear(); if (!App::quitting()) { diff --git a/Telegram/SourceFiles/history/history.h b/Telegram/SourceFiles/history/history.h index c28275ee5..544dd9276 100644 --- a/Telegram/SourceFiles/history/history.h +++ b/Telegram/SourceFiles/history/history.h @@ -108,7 +108,7 @@ private: int _unreadFull = 0; int _unreadMuted = 0; base::Observable _sendActionAnimationUpdated; - OrderedSet _pinnedDialogs; + std::set _pinnedDialogs; base::Timer _selfDestructTimer; std::vector _selfDestructItems; @@ -491,7 +491,7 @@ public: } return result; } - const OrderedSet &overview(qint32 overviewIndex) const { + const std::set &overview(qint32 overviewIndex) const { return _overview[overviewIndex]; } MsgId overviewMinId(qint32 overviewIndex) const { @@ -499,7 +499,7 @@ public: } void overviewSliceDone(qint32 overviewIndex, const MTPmessages_Messages &result, bool onlyCounts = false); bool overviewHasMsgId(qint32 overviewIndex, MsgId msgId) const { - return _overview[overviewIndex].contains(msgId); + return _overview[overviewIndex].find(msgId) != _overview[overviewIndex].end(); } void changeMsgId(MsgId oldId, MsgId newId); @@ -587,7 +587,7 @@ private: } quint64 _sortKeyInChatList = 0; // like ((unixtime) << 32) | (incremented counter) - OrderedSet _overview[OverviewCount]; + std::set _overview[OverviewCount]; qint32 _overviewCountData[OverviewCount]; // -1 - not loaded, 0 - all loaded, > 0 - count, but not all loaded // A pointer to the block that is currently being built. diff --git a/Telegram/SourceFiles/history/history_item.cpp b/Telegram/SourceFiles/history/history_item.cpp index b605cbce7..57b533893 100644 --- a/Telegram/SourceFiles/history/history_item.cpp +++ b/Telegram/SourceFiles/history/history_item.cpp @@ -728,7 +728,7 @@ void HistoryItem::destroy() { history()->setUnreadCount(history()->unreadCount() - 1); } } - Global::RefPendingRepaintItems().remove(this); + Global::RefPendingRepaintItems().erase(this); delete this; } diff --git a/Telegram/SourceFiles/history/history_message.cpp b/Telegram/SourceFiles/history/history_message.cpp index 2cab1cfe6..ecbd9a130 100644 --- a/Telegram/SourceFiles/history/history_message.cpp +++ b/Telegram/SourceFiles/history/history_message.cpp @@ -164,7 +164,7 @@ void FastShareMessage(not_null item) { ShareData(const FullMsgId &msgId) : msgId(msgId) {} FullMsgId msgId; - OrderedSet requests; + std::set requests; }; auto data = MakeShared(item->fullId()); auto isGame = item->getMessageBot() && item->getMedia() && (item->getMedia()->type() == MediaTypeGame); @@ -233,7 +233,7 @@ void FastShareMessage(not_null item) { if (auto main = App::main()) { main->sentUpdatesReceived(updates); } - data->requests.remove(requestId); + data->requests.erase(requestId); if (data->requests.empty()) { Ui::Toast::Show(lang(lng_share_done)); Ui::hideLayer(); diff --git a/Telegram/SourceFiles/inline_bots/inline_bot_layout_item.cpp b/Telegram/SourceFiles/inline_bots/inline_bot_layout_item.cpp index 1ee847c7e..9cdf901ca 100644 --- a/Telegram/SourceFiles/inline_bots/inline_bot_layout_item.cpp +++ b/Telegram/SourceFiles/inline_bots/inline_bot_layout_item.cpp @@ -227,7 +227,7 @@ void unregDocumentItem(DocumentData *document, ItemBase *item) { if (documentItemsMap) { auto i = documentItemsMap->find(document); if (i != documentItemsMap->cend()) { - if (i->remove(item) && i->isEmpty()) { + if (i->erase(item) && i->empty()) { documentItemsMap->erase(i); } } diff --git a/Telegram/SourceFiles/inline_bots/inline_bot_layout_item.h b/Telegram/SourceFiles/inline_bots/inline_bot_layout_item.h index fd180570f..a89f93da7 100644 --- a/Telegram/SourceFiles/inline_bots/inline_bot_layout_item.h +++ b/Telegram/SourceFiles/inline_bots/inline_bot_layout_item.h @@ -129,7 +129,7 @@ private: not_null _context; }; -using DocumentItems = QMap>; +using DocumentItems = QMap>; const DocumentItems *documentItems(); namespace internal { diff --git a/Telegram/SourceFiles/lang/lang_instance.cpp b/Telegram/SourceFiles/lang/lang_instance.cpp index a9669bcd0..3ee676475 100644 --- a/Telegram/SourceFiles/lang/lang_instance.cpp +++ b/Telegram/SourceFiles/lang/lang_instance.cpp @@ -64,7 +64,7 @@ private: const char *_end = nullptr; QString _result; - OrderedSet _tagsUsed; + std::set _tagsUsed; }; ValueParser::ValueParser(const QByteArray &key, LangKey keyIndex, const QByteArray &value) @@ -118,7 +118,7 @@ bool ValueParser::readTag() { if (!IsTagReplaced(_keyIndex, _currentTagIndex)) { return logError("Unexpected tag"); } - if (_tagsUsed.contains(_currentTagIndex)) { + if (_tagsUsed.find(_currentTagIndex) != _tagsUsed.end()) { return logError("Repeated tag"); } _tagsUsed.insert(_currentTagIndex); diff --git a/Telegram/SourceFiles/mainwidget.cpp b/Telegram/SourceFiles/mainwidget.cpp index 2cc9620a9..a00fda0e1 100644 --- a/Telegram/SourceFiles/mainwidget.cpp +++ b/Telegram/SourceFiles/mainwidget.cpp @@ -675,7 +675,7 @@ void MainWidget::gameUpdated(GameData *data) { void MainWidget::webPagesOrGamesUpdate() { _webPageOrGameUpdater.stop(); - if (!_webPagesUpdated.isEmpty()) { + if (!_webPagesUpdated.empty()) { auto &items = App::webPageItems(); for_const (auto webPageId, _webPagesUpdated) { auto j = items.constFind(App::webPage(webPageId)); @@ -685,7 +685,7 @@ void MainWidget::webPagesOrGamesUpdate() { } _webPagesUpdated.clear(); } - if (!_gamesUpdated.isEmpty()) { + if (!_gamesUpdated.empty()) { auto &items = App::gameItems(); for_const (auto gameId, _gamesUpdated) { auto j = items.constFind(App::game(gameId)); diff --git a/Telegram/SourceFiles/mainwidget.h b/Telegram/SourceFiles/mainwidget.h index a6c1543a1..d6b928b5c 100644 --- a/Telegram/SourceFiles/mainwidget.h +++ b/Telegram/SourceFiles/mainwidget.h @@ -598,8 +598,8 @@ private: not_null _controller; bool _started = false; - OrderedSet _webPagesUpdated; - OrderedSet _gamesUpdated; + std::set _webPagesUpdated; + std::set _gamesUpdated; QTimer _webPageOrGameUpdater; SingleTimer _updateMutedTimer; diff --git a/Telegram/SourceFiles/mediaview.cpp b/Telegram/SourceFiles/mediaview.cpp index d3bbb7c6a..1fcfe19eb 100644 --- a/Telegram/SourceFiles/mediaview.cpp +++ b/Telegram/SourceFiles/mediaview.cpp @@ -428,13 +428,12 @@ void MediaView::updateControls() { if (_photo || (_history && _overview != OverviewCount)) { _leftNavVisible = (_index > 0) || - (_index == 0 && - ((!_msgmigrated && _history && - _history->overview(_overview).size() < _history->overviewCount(_overview)) || - (_msgmigrated && _migrated && - _migrated->overview(_overview).size() < _migrated->overviewCount(_overview)) || - (!_msgmigrated && _history && _migrated && - (!_migrated->overview(_overview).isEmpty() || _migrated->overviewCount(_overview) > 0)))) || + (_index == 0 && ((!_msgmigrated && _history && + _history->overview(_overview).size() < _history->overviewCount(_overview)) || + (_msgmigrated && _migrated && + _migrated->overview(_overview).size() < _migrated->overviewCount(_overview)) || + (!_msgmigrated && _history && _migrated && + (!_migrated->overview(_overview).empty() || _migrated->overviewCount(_overview) > 0)))) || (_index < 0 && _photo == _additionalChatPhoto && ((_history && _history->overviewCount(_overview) > 0) || (_migrated && _history->overviewLoaded(_overview) && _migrated->overviewCount(_overview) > 0))); @@ -443,7 +442,7 @@ void MediaView::updateControls() { ((!_msgmigrated && _history && _index + 1 < _history->overview(_overview).size()) || (_msgmigrated && _migrated && _index + 1 < _migrated->overview(_overview).size()) || (_msgmigrated && _migrated && _history && - (!_history->overview(_overview).isEmpty() || _history->overviewCount(_overview) > 0)) || + (!_history->overview(_overview).empty() || _history->overviewCount(_overview) > 0)) || (!_msgmigrated && _history && _index + 1 == _history->overview(_overview).size() && _additionalChatPhoto) || (_msgmigrated && _migrated && _index + 1 == _migrated->overview(_overview).size() && @@ -2959,7 +2958,7 @@ void MediaView::loadBack() { } else { App::main()->loadMediaBack(_history->peer, _overview); if (_migrated && _index == 0 && - (_migrated->overviewCount(_overview) < 0 || _migrated->overview(_overview).isEmpty()) && + (_migrated->overviewCount(_overview) < 0 || _migrated->overview(_overview).empty()) && !_migrated->overviewLoaded(_overview)) { App::main()->loadMediaBack(_migrated->peer, _overview); } @@ -2994,13 +2993,13 @@ MediaView::LastChatPhoto MediaView::computeLastOverviewChatPhoto() { if (!_history) return emptyResult; auto &list = _history->overview(OverviewChatPhotos); - if (!list.isEmpty()) { + if (!list.empty()) { return lastPhotoInOverview(_history, list); } if (!_migrated || !_history->overviewLoaded(OverviewChatPhotos)) return emptyResult; auto &migratedList = _migrated->overview(OverviewChatPhotos); - if (!migratedList.isEmpty()) { + if (!migratedList.empty()) { return lastPhotoInOverview(_migrated, migratedList); } return emptyResult; @@ -3058,8 +3057,8 @@ void MediaView::updateHeader() { if (_history) { if (_overview != OverviewCount) { bool lastOverviewPhotoLoaded = - (!_history->overview(_overview).isEmpty() || - (_migrated && _history->overviewCount(_overview) == 0 && !_migrated->overview(_overview).isEmpty())); + (!_history->overview(_overview).empty() || + (_migrated && _history->overviewCount(_overview) == 0 && !_migrated->overview(_overview).empty())); count = _history->overviewCount(_overview); if (addcount >= 0 && count >= 0) { count += addcount; diff --git a/Telegram/SourceFiles/overviewwidget.cpp b/Telegram/SourceFiles/overviewwidget.cpp index d641acd34..26850e8de 100644 --- a/Telegram/SourceFiles/overviewwidget.cpp +++ b/Telegram/SourceFiles/overviewwidget.cpp @@ -810,8 +810,8 @@ void OverviewInner::paintEvent(QPaintEvent *e) { auto ms = getms(); Overview::Layout::PaintContext context(ms, _selMode); - if (_history->overview(_type).isEmpty() && - (!_migrated || !_history->overviewLoaded(_type) || _migrated->overview(_type).isEmpty())) { + if (_history->overview(_type).empty() && + (!_migrated || !_history->overviewLoaded(_type) || _migrated->overview(_type).empty())) { HistoryLayout::paintEmpty(p, _width, height()); return; } else if (_inSearch && _searchResults.isEmpty() && _searchFull && (!_migrated || _searchFullMigrated) && @@ -1681,7 +1681,7 @@ void OverviewInner::mediaOverviewUpdated() { auto migratedOverview = _migrated ? &_migrated->overview(_type) : nullptr; auto migrateCount = migratedIndexSkip(); auto fullCount = (migrateCount + o.size()); - auto tocheck = std::min(fullCount, _itemsToBeLoaded); + auto tocheck = std::min((qint32)fullCount, _itemsToBeLoaded); _items.reserve(tocheck); auto index = 0; @@ -1723,7 +1723,7 @@ void OverviewInner::mediaOverviewUpdated() { auto migratedOverview = _migrated ? &_migrated->overview(_type) : nullptr; auto migrateCount = migratedIndexSkip(); auto l = _inSearch ? _searchResults.size() : (migrateCount + o.size()); - auto tocheck = std::min(l, _itemsToBeLoaded); + auto tocheck = std::min((qint32)l, _itemsToBeLoaded); _items.reserve((withDates ? 2 : 1) * tocheck); // day items auto migrateIt = migratedOverview ? migratedOverview->end() : o.end(); @@ -2311,9 +2311,9 @@ void OverviewWidget::mediaOverviewUpdated(const Notify::PeerUpdate &update) { History *m = (update.peer && update.peer->migrateFrom()) ? App::historyLoaded(update.peer->migrateFrom()->id) : 0; if (h) { for (qint32 i = 0; i < OverviewCount; ++i) { - if (!h->overview(i).isEmpty() || h->overviewCount(i) > 0 || i == type()) { + if (!h->overview(i).empty() || h->overviewCount(i) > 0 || i == type()) { mask |= (1 << i); - } else if (m && (!m->overview(i).isEmpty() || m->overviewCount(i) > 0)) { + } else if (m && (!m->overview(i).empty() || m->overviewCount(i) > 0)) { mask |= (1 << i); } } diff --git a/Telegram/SourceFiles/platform/linux/specific_linux.cpp b/Telegram/SourceFiles/platform/linux/specific_linux.cpp index b86717b18..92e970936 100644 --- a/Telegram/SourceFiles/platform/linux/specific_linux.cpp +++ b/Telegram/SourceFiles/platform/linux/specific_linux.cpp @@ -384,8 +384,8 @@ bool TranslucentWindowsSupported(QPoint globalPosition) { return true; } - static OrderedSet WarnedAbout; - if (!WarnedAbout.contains(index)) { + static std::set WarnedAbout; + if (WarnedAbout.find(index) == WarnedAbout.end()) { WarnedAbout.insert(index); LOG(("WARNING: Compositing is disabled for screen index %1 (for position %2,%3)") .arg(index) diff --git a/Telegram/SourceFiles/profile/profile_block_group_members.cpp b/Telegram/SourceFiles/profile/profile_block_group_members.cpp index a9255ec88..dcc2789a6 100644 --- a/Telegram/SourceFiles/profile/profile_block_group_members.cpp +++ b/Telegram/SourceFiles/profile/profile_block_group_members.cpp @@ -321,10 +321,10 @@ void GroupMembersWidget::checkSelfAdmin(ChatData *chat) { if (chat->participants.isEmpty()) return; auto self = App::self(); - if (chat->amAdmin() && !chat->admins.contains(self)) { + if (chat->amAdmin() && (chat->admins.find(self) == chat->admins.end())) { chat->admins.insert(self); - } else if (!chat->amAdmin() && chat->admins.contains(self)) { - chat->admins.remove(self); + } else if (!chat->amAdmin() && (chat->admins.find(self) != chat->admins.end())) { + chat->admins.erase(self); } } @@ -392,14 +392,14 @@ void GroupMembersWidget::setItemFlags(Item *item, ChatData *chat) { using AdminState = Item::AdminState; auto user = getMember(item)->user(); auto isCreator = (peerFromUser(chat->creator) == item->peer->id); - auto isAdmin = chat->adminsEnabled() && chat->admins.contains(user); + auto isAdmin = chat->adminsEnabled() && chat->admins.find(user) != chat->admins.end(); auto adminState = isCreator ? AdminState::Creator : isAdmin ? AdminState::Admin : AdminState::None; item->adminState = adminState; if (item->peer->id == Auth().userPeerId()) { item->hasRemoveLink = false; } else if (chat->amCreator() || (chat->amAdmin() && (adminState == AdminState::None))) { item->hasRemoveLink = true; - } else if (chat->invitedByMe.contains(user) && (adminState == AdminState::None)) { + } else if (chat->invitedByMe.find(user) != chat->invitedByMe.end() && (adminState == AdminState::None)) { item->hasRemoveLink = true; } else { item->hasRemoveLink = false; diff --git a/Telegram/SourceFiles/profile/profile_channel_controllers.cpp b/Telegram/SourceFiles/profile/profile_channel_controllers.cpp index 466b88054..b746cef95 100644 --- a/Telegram/SourceFiles/profile/profile_channel_controllers.cpp +++ b/Telegram/SourceFiles/profile/profile_channel_controllers.cpp @@ -1428,7 +1428,7 @@ void AddParticipantBoxSearchController::addChatsContacts() { auto dialogsIndex = getSmallestIndex(App::main()->dialogsList()); auto contactsIndex = getSmallestIndex(App::main()->contactsNoDialogsList()); - auto allWordsAreFound = [&wordList](const OrderedSet &names) { + auto allWordsAreFound = [&wordList](const std::set &names) { auto hasNamePartStartingWith = [&names](const QString &word) { for_const (auto &namePart, names) { if (namePart.startsWith(word)) { diff --git a/Telegram/SourceFiles/storage/file_download.cpp b/Telegram/SourceFiles/storage/file_download.cpp index 81a3b5a18..394d09ed8 100644 --- a/Telegram/SourceFiles/storage/file_download.cpp +++ b/Telegram/SourceFiles/storage/file_download.cpp @@ -1212,7 +1212,7 @@ void WebLoadManager::onFailed(QNetworkReply *reply) { .arg(reply->errorString())); if (!handleReplyResult(loader, WebReplyProcessError)) { - _loaders.remove(loader); + _loaders.erase(loader); delete loader; } } @@ -1263,7 +1263,7 @@ void WebLoadManager::onProgress(qint64 already, qint64 size) { } if (!handleReplyResult(loader, result)) { _replies.erase(j); - _loaders.remove(loader); + _loaders.erase(loader); delete loader; reply->abort(); @@ -1292,7 +1292,7 @@ void WebLoadManager::onMeta() { m.captured(1).toLongLong()); if (!handleReplyResult(loader, WebReplyProcessProgress)) { _replies.erase(j); - _loaders.remove(loader); + _loaders.erase(loader); delete loader; reply->abort(); @@ -1336,7 +1336,7 @@ void WebLoadManager::process() { } } for_const (webFileLoaderPrivate *loader, newLoaders) { - if (_loaders.contains(loader)) { + if (_loaders.erase(loader)) { sendRequest(loader); } } diff --git a/Telegram/SourceFiles/storage/file_download.h b/Telegram/SourceFiles/storage/file_download.h index 226cbf897..d738f1bf9 100644 --- a/Telegram/SourceFiles/storage/file_download.h +++ b/Telegram/SourceFiles/storage/file_download.h @@ -377,7 +377,7 @@ private: LoaderPointers _loaderPointers; mutable QMutex _loaderPointersMutex; - typedef OrderedSet Loaders; + typedef std::set Loaders; Loaders _loaders; typedef QMap Replies; diff --git a/Telegram/SourceFiles/storage/localstorage.cpp b/Telegram/SourceFiles/storage/localstorage.cpp index e37d5a708..7f4a2a4ea 100644 --- a/Telegram/SourceFiles/storage/localstorage.cpp +++ b/Telegram/SourceFiles/storage/localstorage.cpp @@ -625,7 +625,7 @@ WebFilesMap _webFilesMap; quint64 _storageWebFilesSize = 0; FileKey _locationsKey = 0, _reportSpamStatusesKey = 0, _trustedBotsKey = 0; -using TrustedBots = OrderedSet; +using TrustedBots = std::set; TrustedBots _trustedBots; bool _trustedBotsRead = false; @@ -3451,12 +3451,12 @@ void _readStickerSets(FileKey &stickersKey, Stickers::Order *outOrder = nullptr, } Serialize::Document::StickerSetInfo info(setId, setAccess, setShortName); - OrderedSet read; + std::set read; for (qint32 j = 0; j < scnt; ++j) { auto document = Serialize::Document::readStickerFromStream(stickers.version, stickers.stream, info); if (!document || !document->sticker()) continue; - if (read.contains(document->id)) continue; + if (read.find(document->id) != read.end()) continue; read.insert(document->id); if (fillStickers) { @@ -3838,12 +3838,12 @@ void readSavedGifs() { quint32 cnt; gifs.stream >> cnt; saved.reserve(cnt); - OrderedSet read; + std::set read; for (quint32 i = 0; i < cnt; ++i) { auto document = Serialize::Document::readFromStream(gifs.version, gifs.stream); if (!document || !document->isGifv()) continue; - if (read.contains(document->id)) continue; + if (read.find(document->id) != read.end()) continue; read.insert(document->id); saved.push_back(document); @@ -4462,7 +4462,7 @@ void writeReportSpamStatuses() { void writeTrustedBots() { if (!_working()) return; - if (_trustedBots.isEmpty()) { + if (_trustedBots.empty()) { if (_trustedBotsKey) { clearKey(_trustedBotsKey); _trustedBotsKey = 0; @@ -4517,7 +4517,7 @@ bool isBotTrusted(UserData *bot) { readTrustedBots(); _trustedBotsRead = true; } - return _trustedBots.contains(bot->id); + return _trustedBots.find(bot->id) != _trustedBots.end(); } bool encrypt(const void *src, void *dst, quint32 len, const void *key128) { diff --git a/Telegram/SourceFiles/structs.cpp b/Telegram/SourceFiles/structs.cpp index ff876ecc6..f056eb62c 100644 --- a/Telegram/SourceFiles/structs.cpp +++ b/Telegram/SourceFiles/structs.cpp @@ -795,7 +795,7 @@ void ChannelData::applyEditAdmin(not_null user, const MTPChannelAdmi if (!mgInfo->lastParticipants.contains(user)) { // If rights are empty - still add participant? TODO check mgInfo->lastParticipants.push_front(user); setMembersCount(membersCount() + 1); - if (user->botInfo && !mgInfo->bots.contains(user)) { + if (user->botInfo && mgInfo->bots.find(user) == mgInfo->bots.end()) { mgInfo->bots.insert(user); if (mgInfo->botStatus != 0 && mgInfo->botStatus < 2) { mgInfo->botStatus = 2; @@ -885,9 +885,9 @@ void ChannelData::applyEditBanned(not_null user, const MTPChannelBan mgInfo->lastParticipantsCount = 0; } setKickedCount(kickedCount() + 1); - if (mgInfo->bots.contains(user)) { - mgInfo->bots.remove(user); - if (mgInfo->bots.isEmpty() && mgInfo->botStatus > 0) { + if (mgInfo->bots.find(user) != mgInfo->bots.end()) { + mgInfo->bots.erase(user); + if (mgInfo->bots.empty() && mgInfo->botStatus > 0) { mgInfo->botStatus = -1; } } diff --git a/Telegram/SourceFiles/structs.h b/Telegram/SourceFiles/structs.h index f005b6b50..d4e66895a 100644 --- a/Telegram/SourceFiles/structs.h +++ b/Telegram/SourceFiles/structs.h @@ -358,9 +358,9 @@ public: QString name; Text nameText; - using Names = OrderedSet; + using Names = std::set; Names names; // for filtering - using NameFirstChars = OrderedSet; + using NameFirstChars = std::set; NameFirstChars chars; enum LoadedStatus { @@ -651,10 +651,10 @@ public: return flags & MTPDchat::Flag::f_migrated_to; } QMap, int> participants; - OrderedSet> invitedByMe; - OrderedSet> admins; + std::set> invitedByMe; + std::set> admins; QList> lastAuthors; - OrderedSet> markupSenders; + std::set> markupSenders; int botStatus = 0; // -1 - no bots, 0 - unknown, 1 - one bot, that sees all history, 2 - other // ImagePtr photoFull; @@ -750,8 +750,8 @@ struct MegagroupInfo { QList> lastParticipants; QMap, Admin> lastAdmins; QMap, Restricted> lastRestricted; - OrderedSet> markupSenders; - OrderedSet> bots; + std::set> markupSenders; + std::set> bots; UserData *creator = nullptr; // nullptr means unknown int botStatus = 0; // -1 - no bots, 0 - unknown, 1 - one bot, that sees all history, 2 - other diff --git a/Telegram/SourceFiles/ui/animation.cpp b/Telegram/SourceFiles/ui/animation.cpp index 07a7a9b3a..29b98bb50 100644 --- a/Telegram/SourceFiles/ui/animation.cpp +++ b/Telegram/SourceFiles/ui/animation.cpp @@ -138,11 +138,11 @@ AnimationManager::AnimationManager() void AnimationManager::start(BasicAnimation *obj) { if (_iterating) { _starting.insert(obj); - if (!_stopping.isEmpty()) { - _stopping.remove(obj); + if (!_stopping.empty()) { + _stopping.erase(obj); } } else { - if (_objects.isEmpty()) { + if (_objects.empty()) { _timer.start(AnimationTimerDelta); } _objects.insert(obj); @@ -152,8 +152,8 @@ void AnimationManager::start(BasicAnimation *obj) { void AnimationManager::stop(BasicAnimation *obj) { if (_iterating) { _stopping.insert(obj); - if (!_starting.isEmpty()) { - _starting.remove(obj); + if (!_starting.empty()) { + _starting.erase(obj); } } else { auto i = _objects.find(obj); @@ -170,18 +170,18 @@ void AnimationManager::timeout() { _iterating = true; auto ms = getms(); for_const (auto object, _objects) { - if (!_stopping.contains(object)) { + if (_stopping.find(object) == _stopping.end()) { object->step(ms, true); } } _iterating = false; - if (!_starting.isEmpty()) { + if (!_starting.empty()) { for_const (auto object, _starting) { _objects.insert(object); } _starting.clear(); } - if (!_stopping.isEmpty()) { - for_const (auto object, _stopping) { _objects.remove(object); } + if (!_stopping.empty()) { + for_const (auto object, _stopping) { _objects.erase(object); } _stopping.clear(); } if (_objects.empty()) { diff --git a/Telegram/SourceFiles/ui/animation.h b/Telegram/SourceFiles/ui/animation.h index 3896052e6..ee136f5f2 100644 --- a/Telegram/SourceFiles/ui/animation.h +++ b/Telegram/SourceFiles/ui/animation.h @@ -710,7 +710,7 @@ public slots: void clipCallback(Media::Clip::Reader *reader, qint32 threadIndex, qint32 notification); private: - using AnimatingObjects = OrderedSet; + using AnimatingObjects = std::set; AnimatingObjects _objects, _starting, _stopping; QTimer _timer; bool _iterating; diff --git a/Telegram/SourceFiles/ui/style/style_core_icon.cpp b/Telegram/SourceFiles/ui/style/style_core_icon.cpp index 5429538a9..6d7cc7810 100644 --- a/Telegram/SourceFiles/ui/style/style_core_icon.cpp +++ b/Telegram/SourceFiles/ui/style/style_core_icon.cpp @@ -35,7 +35,7 @@ quint32 colorKey(QColor c) { using IconMasks = QMap; using IconPixmaps = QMap, QPixmap>; -using IconDatas = OrderedSet; +using IconDatas = std::set; NeverFreedPointer iconMasks; NeverFreedPointer iconPixmaps; NeverFreedPointer iconData; diff --git a/Telegram/SourceFiles/ui/toast/toast_manager.h b/Telegram/SourceFiles/ui/toast/toast_manager.h index 1f7e33ac3..24628151a 100644 --- a/Telegram/SourceFiles/ui/toast/toast_manager.h +++ b/Telegram/SourceFiles/ui/toast/toast_manager.h @@ -58,7 +58,7 @@ private: QMultiMap _toastByHideTime; QMap _toastByWidget; QList _toasts; - OrderedSet> _toastParents; + std::set> _toastParents; }; } // namespace internal diff --git a/Telegram/SourceFiles/window/themes/window_theme_editor.cpp b/Telegram/SourceFiles/window/themes/window_theme_editor.cpp index b2b94c960..6cac4d86b 100644 --- a/Telegram/SourceFiles/window/themes/window_theme_editor.cpp +++ b/Telegram/SourceFiles/window/themes/window_theme_editor.cpp @@ -158,7 +158,7 @@ bool isValidColorValue(QLatin1String value) { } QByteArray replaceValueInContent(const QByteArray &content, const QByteArray &name, const QByteArray &value) { - auto validNames = OrderedSet(); + auto validNames = std::set(); auto start = content.constBegin(), data = start, end = data + content.size(); auto lastValidValueStart = end, lastValidValueEnd = end; while (data != end) { @@ -178,7 +178,7 @@ QByteArray replaceValueInContent(const QByteArray &content, const QByteArray &na if (value.size() == 0) { return "error"; } - auto validValue = validNames.contains(value) || isValidColorValue(value); + auto validValue = validNames.find(value) != validNames.end() || isValidColorValue(value); if (validValue) { validNames.insert(foundName); if (foundName == name) { diff --git a/Telegram/SourceFiles/window/themes/window_theme_editor_block.cpp b/Telegram/SourceFiles/window/themes/window_theme_editor_block.cpp index 7d13fbf28..6a4139a1a 100644 --- a/Telegram/SourceFiles/window/themes/window_theme_editor_block.cpp +++ b/Telegram/SourceFiles/window/themes/window_theme_editor_block.cpp @@ -69,7 +69,7 @@ public: fillSearchIndex(); } - const OrderedSet &searchWords() const { + const std::set &searchWords() const { return _searchWords; } bool searchWordsContain(const QString &needle) const { @@ -81,7 +81,7 @@ public: return false; } - const OrderedSet &searchStartChars() const { + const std::set &searchStartChars() const { return _searchStartChars; } @@ -120,8 +120,8 @@ private: QString _valueString; Text _description = {st::windowMinWidth / 2}; - OrderedSet _searchWords; - OrderedSet _searchStartChars; + std::set _searchWords; + std::set _searchStartChars; int _top = 0; int _height = 0; @@ -281,8 +281,8 @@ void EditorBlock::removeFromSearch(const Row &row) { for_const (auto ch, row.searchStartChars()) { auto it = _searchIndex.find(ch); if (it != _searchIndex.cend()) { - it->remove(index); - if (it->isEmpty()) { + it->erase(index); + if (it->empty()) { _searchIndex.erase(it); } } @@ -356,19 +356,19 @@ void EditorBlock::searchByQuery(QString query) { _searchQuery = query; _searchResults.clear(); - auto toFilter = OrderedSet(); + auto toFilter = std::set(); for_const (auto &word, words) { if (word.isEmpty()) continue; auto testToFilter = _searchIndex.value(word[0]); - if (testToFilter.isEmpty()) { + if (testToFilter.empty()) { toFilter.clear(); break; - } else if (toFilter.isEmpty() || testToFilter.size() < toFilter.size()) { + } else if (toFilter.empty() || testToFilter.size() < toFilter.size()) { toFilter = testToFilter; } } - if (!toFilter.isEmpty()) { + if (!toFilter.empty()) { auto allWordsFound = [&words](const Row &row) { for_const (auto &word, words) { if (!row.searchWordsContain(word)) { diff --git a/Telegram/SourceFiles/window/themes/window_theme_editor_block.h b/Telegram/SourceFiles/window/themes/window_theme_editor_block.h index ca97a5f20..4a30c0668 100644 --- a/Telegram/SourceFiles/window/themes/window_theme_editor_block.h +++ b/Telegram/SourceFiles/window/themes/window_theme_editor_block.h @@ -153,7 +153,7 @@ private: QString _searchQuery; QVector _searchResults; - QMap> _searchIndex; + QMap> _searchIndex; int _selected = -1; int _pressed = -1;