Get rid of OrderedSet

This commit is contained in:
Evgenii Zheltonozhskii 2018-06-14 12:28:48 +03:00 committed by Alex
parent 8b189226e4
commit b6df430aa8
48 changed files with 150 additions and 435 deletions

View File

@ -983,7 +983,7 @@ void ApiWrap::saveStickerSets(const Stickers::Order &localOrder, const Stickers:
if (writeFaved) Local::writeFavedStickers(); if (writeFaved) Local::writeFavedStickers();
Auth().data().stickersUpdated().notify(true); Auth().data().stickersUpdated().notify(true);
if (_stickerSetDisenableRequests.isEmpty()) { if (_stickerSetDisenableRequests.empty()) {
stickersSaveOrder(); stickersSaveOrder();
} else { } else {
requestSendDelayed(); requestSendDelayed();
@ -991,8 +991,8 @@ void ApiWrap::saveStickerSets(const Stickers::Order &localOrder, const Stickers:
} }
void ApiWrap::stickerSetDisenabled(mtpRequestId requestId) { void ApiWrap::stickerSetDisenabled(mtpRequestId requestId) {
_stickerSetDisenableRequests.remove(requestId); _stickerSetDisenableRequests.erase(requestId);
if (_stickerSetDisenableRequests.isEmpty()) { if (_stickerSetDisenableRequests.empty()) {
stickersSaveOrder(); stickersSaveOrder();
} }
}; };
@ -1396,7 +1396,7 @@ void ApiWrap::resolveWebPages() {
if (i.value() > 0) continue; if (i.value() > 0) continue;
if (i.key()->pendingTill <= t) { if (i.key()->pendingTill <= t) {
auto j = items.constFind(i.key()); 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()) { for_const (auto item, j.value()) {
if (item->id > 0) { if (item->id > 0) {
if (item->channelId() == NoChannel) { if (item->channelId() == NoChannel) {
@ -2001,7 +2001,7 @@ void ApiWrap::sendSaveChatAdminsRequests(not_null<ChatData *> chat) {
chat->admins.insert(user); chat->admins.insert(user);
} }
} else { } else {
chat->admins.remove(user); chat->admins.erase(user);
} }
} }
}) })
@ -2031,7 +2031,7 @@ void ApiWrap::sendSaveChatAdminsRequests(not_null<ChatData *> chat) {
if (!admins->empty()) { if (!admins->empty()) {
toAppoint.reserve(admins->size()); toAppoint.reserve(admins->size());
for (auto user : *admins) { 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); toAppoint.push_back(user);
} }
} }

View File

@ -192,7 +192,7 @@ private:
QMap<History *, mtpRequestId> _draftsSaveRequestIds; QMap<History *, mtpRequestId> _draftsSaveRequestIds;
base::Timer _draftsSaveTimer; base::Timer _draftsSaveTimer;
OrderedSet<mtpRequestId> _stickerSetDisenableRequests; std::set<mtpRequestId> _stickerSetDisenableRequests;
Stickers::Order _stickersOrder; Stickers::Order _stickersOrder;
mtpRequestId _stickersReorderRequestId = 0; mtpRequestId _stickersReorderRequestId = 0;
mtpRequestId _stickersClearRecentRequestId = 0; mtpRequestId _stickersClearRecentRequestId = 0;

View File

@ -85,7 +85,7 @@ GameItems gameItems;
SharedContactItems sharedContactItems; SharedContactItems sharedContactItems;
GifItems gifItems; GifItems gifItems;
using DependentItemsSet = OrderedSet<HistoryItem *>; using DependentItemsSet = std::set<HistoryItem *>;
using DependentItems = QMap<HistoryItem *, DependentItemsSet>; using DependentItems = QMap<HistoryItem *, DependentItemsSet>;
DependentItems dependentItems; DependentItems dependentItems;
@ -897,7 +897,7 @@ void feedParticipantAdd(const MTPDupdateChatParticipantAdd &d) {
if (d.vinviter_id.v == Auth().userId()) { if (d.vinviter_id.v == Auth().userId()) {
chat->invitedByMe.insert(user); chat->invitedByMe.insert(user);
} else { } else {
chat->invitedByMe.remove(user); chat->invitedByMe.erase(user);
} }
chat->count++; chat->count++;
if (user->botInfo) { if (user->botInfo) {
@ -935,8 +935,8 @@ void feedParticipantDelete(const MTPDupdateChatParticipantDelete &d) {
if (i != chat->participants.end()) { if (i != chat->participants.end()) {
chat->participants.erase(i); chat->participants.erase(i);
chat->count--; chat->count--;
chat->invitedByMe.remove(user); chat->invitedByMe.erase(user);
chat->admins.remove(user); chat->admins.erase(user);
if (user->isSelf()) { if (user->isSelf()) {
chat->flags &= ~MTPDchat::Flag::f_admin; chat->flags &= ~MTPDchat::Flag::f_admin;
} }
@ -1016,7 +1016,7 @@ void feedParticipantAdmin(const MTPDupdateChatParticipantAdmin &d) {
if (user->isSelf()) { if (user->isSelf()) {
chat->flags &= ~MTPDchat::Flag::f_admin; chat->flags &= ~MTPDchat::Flag::f_admin;
} }
chat->admins.remove(user); chat->admins.erase(user);
} }
} else { } else {
chat->invalidateParticipants(); chat->invalidateParticipants();
@ -2151,8 +2151,8 @@ void historyRegDependency(HistoryItem *dependent, HistoryItem *dependency) {
void historyUnregDependency(HistoryItem *dependent, HistoryItem *dependency) { void historyUnregDependency(HistoryItem *dependent, HistoryItem *dependency) {
auto i = ::dependentItems.find(dependency); auto i = ::dependentItems.find(dependency);
if (i != ::dependentItems.cend()) { if (i != ::dependentItems.cend()) {
i.value().remove(dependent); i.value().erase(dependent);
if (i.value().isEmpty()) { if (i.value().empty()) {
::dependentItems.erase(i); ::dependentItems.erase(i);
} }
} }
@ -2578,7 +2578,7 @@ void regPhotoItem(PhotoData *data, HistoryItem *item) {
} }
void unregPhotoItem(PhotoData *data, HistoryItem *item) { void unregPhotoItem(PhotoData *data, HistoryItem *item) {
::photoItems[data].remove(item); ::photoItems[data].erase(item);
} }
const PhotoItems &photoItems() { const PhotoItems &photoItems() {
@ -2594,7 +2594,7 @@ void regDocumentItem(DocumentData *data, HistoryItem *item) {
} }
void unregDocumentItem(DocumentData *data, HistoryItem *item) { void unregDocumentItem(DocumentData *data, HistoryItem *item) {
::documentItems[data].remove(item); ::documentItems[data].erase(item);
} }
const DocumentItems &documentItems() { const DocumentItems &documentItems() {
@ -2610,7 +2610,7 @@ void regWebPageItem(WebPageData *data, HistoryItem *item) {
} }
void unregWebPageItem(WebPageData *data, HistoryItem *item) { void unregWebPageItem(WebPageData *data, HistoryItem *item) {
::webPageItems[data].remove(item); ::webPageItems[data].erase(item);
} }
const WebPageItems &webPageItems() { const WebPageItems &webPageItems() {
@ -2622,7 +2622,7 @@ void regGameItem(GameData *data, HistoryItem *item) {
} }
void unregGameItem(GameData *data, HistoryItem *item) { void unregGameItem(GameData *data, HistoryItem *item) {
::gameItems[data].remove(item); ::gameItems[data].erase(item);
} }
const GameItems &gameItems() { const GameItems &gameItems() {
@ -2641,7 +2641,7 @@ void regSharedContactItem(qint32 userId, HistoryItem *item) {
void unregSharedContactItem(qint32 userId, HistoryItem *item) { void unregSharedContactItem(qint32 userId, HistoryItem *item) {
auto user = App::userLoaded(userId); auto user = App::userLoaded(userId);
auto canShareThisContact = user ? user->canShareThisContact() : false; auto canShareThisContact = user ? user->canShareThisContact() : false;
::sharedContactItems[userId].remove(item); ::sharedContactItems[userId].erase(item);
if (canShareThisContact != (user ? user->canShareThisContact() : false)) { if (canShareThisContact != (user ? user->canShareThisContact() : false)) {
Notify::peerUpdatedDelayed(user, Notify::PeerUpdate::Flag::UserCanShareContact); Notify::peerUpdatedDelayed(user, Notify::PeerUpdate::Flag::UserCanShareContact);
} }
@ -2674,7 +2674,7 @@ void stopGifItems() {
QString phoneFromSharedContact(qint32 userId) { QString phoneFromSharedContact(qint32 userId) {
auto i = ::sharedContactItems.constFind(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 (auto media = (*i->cbegin())->getMedia()) {
if (media->type() == MediaTypeContact) { if (media->type() == MediaTypeContact) {
return static_cast<HistoryContact *>(media)->phone(); return static_cast<HistoryContact *>(media)->phone();

View File

@ -34,7 +34,7 @@ class Messenger;
class MainWindow; class MainWindow;
class MainWidget; class MainWidget;
using HistoryItemsMap = OrderedSet<HistoryItem *>; using HistoryItemsMap = std::set<HistoryItem *>;
using PhotoItems = QHash<PhotoData *, HistoryItemsMap>; using PhotoItems = QHash<PhotoData *, HistoryItemsMap>;
using DocumentItems = QHash<DocumentData *, HistoryItemsMap>; using DocumentItems = QHash<DocumentData *, HistoryItemsMap>;
using WebPageItems = QHash<WebPageData *, HistoryItemsMap>; using WebPageItems = QHash<WebPageData *, HistoryItemsMap>;

View File

@ -89,7 +89,7 @@ void AuthSessionData::constructFromSerialized(const QByteArray &serialized) {
qint32 floatPlayerColumn = static_cast<qint32>(Window::Column::Second); qint32 floatPlayerColumn = static_cast<qint32>(Window::Column::Second);
qint32 floatPlayerCorner = static_cast<qint32>(RectPart::TopRight); qint32 floatPlayerCorner = static_cast<qint32>(RectPart::TopRight);
QMap<QString, QString> soundOverrides; QMap<QString, QString> soundOverrides;
OrderedSet<PeerId> groupStickersSectionHidden; std::set<PeerId> groupStickersSectionHidden;
stream >> selectorTab; stream >> selectorTab;
stream >> lastSeenWarningSeen; stream >> lastSeenWarningSeen;
if (!stream.atEnd()) { if (!stream.atEnd()) {

View File

@ -140,10 +140,10 @@ public:
_variables.groupStickersSectionHidden.insert(peerId); _variables.groupStickersSectionHidden.insert(peerId);
} }
bool isGroupStickersSectionHidden(PeerId peerId) const { bool isGroupStickersSectionHidden(PeerId peerId) const {
return _variables.groupStickersSectionHidden.contains(peerId); return _variables.groupStickersSectionHidden.find(peerId) != _variables.groupStickersSectionHidden.end();
} }
void removeGroupStickersSectionHidden(PeerId peerId) { void removeGroupStickersSectionHidden(PeerId peerId) {
_variables.groupStickersSectionHidden.remove(peerId); _variables.groupStickersSectionHidden.erase(peerId);
} }
private: private:
@ -157,7 +157,7 @@ private:
QMap<QString, QString> soundOverrides; QMap<QString, QString> soundOverrides;
Window::Column floatPlayerColumn; Window::Column floatPlayerColumn;
RectPart floatPlayerCorner; RectPart floatPlayerCorner;
OrderedSet<PeerId> groupStickersSectionHidden; std::set<PeerId> groupStickersSectionHidden;
}; };
base::Variable<bool> _contactsLoaded = {false}; base::Variable<bool> _contactsLoaded = {false};

View File

@ -31,7 +31,7 @@ struct ObservableListWrap {
~ObservableListWrap() { ~ObservableListWrap() {
CantUseObservables = true; CantUseObservables = true;
} }
OrderedSet<ObservableCallHandlers *> list; std::set<ObservableCallHandlers *> list;
}; };
ObservableListWrap &PendingObservables() { ObservableListWrap &PendingObservables() {
@ -54,13 +54,13 @@ void RegisterPendingObservable(ObservableCallHandlers *handlers) {
void UnregisterActiveObservable(ObservableCallHandlers *handlers) { void UnregisterActiveObservable(ObservableCallHandlers *handlers) {
if (CantUseObservables) return; if (CantUseObservables) return;
ActiveObservables().list.remove(handlers); ActiveObservables().list.erase(handlers);
} }
void UnregisterObservable(ObservableCallHandlers *handlers) { void UnregisterObservable(ObservableCallHandlers *handlers) {
if (CantUseObservables) return; if (CantUseObservables) return;
PendingObservables().list.remove(handlers); PendingObservables().list.erase(handlers);
ActiveObservables().list.remove(handlers); ActiveObservables().list.erase(handlers);
} }
} // namespace internal } // namespace internal

View File

@ -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 <QMap>
// ordered set template based on QMap
template <typename T> class OrderedSet {
struct NullType {};
using Self = OrderedSet<T>;
using Impl = QMap<T, NullType>;
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<T> 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<T>;
};
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<T>;
};
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();
}
};

View File

@ -620,7 +620,7 @@ void PeerListBox::Inner::removeFromSearchIndex(not_null<PeerListRow *> row) {
} }
} }
} }
row->setNameFirstChars(OrderedSet<QChar>()); row->setNameFirstChars(std::set<QChar>());
} }
} }

View File

@ -135,10 +135,10 @@ public:
void paintUserpic(Painter &p, TimeMs ms, int x, int y, int outerWidth); void paintUserpic(Painter &p, TimeMs ms, int x, int y, int outerWidth);
double checkedRatio(); double checkedRatio();
void setNameFirstChars(const OrderedSet<QChar> &nameFirstChars) { void setNameFirstChars(const std::set<QChar> &nameFirstChars) {
_nameFirstChars = nameFirstChars; _nameFirstChars = nameFirstChars;
} }
const OrderedSet<QChar> &nameFirstChars() const { const std::set<QChar> &nameFirstChars() const {
return _nameFirstChars; return _nameFirstChars;
} }
@ -163,7 +163,7 @@ private:
Text _name; Text _name;
Text _status; Text _status;
StatusType _statusType = StatusType::Online; StatusType _statusType = StatusType::Online;
OrderedSet<QChar> _nameFirstChars; std::set<QChar> _nameFirstChars;
int _absoluteIndex = -1; int _absoluteIndex = -1;
State _disabledState = State::Active; State _disabledState = State::Active;
bool _initialized : 1; bool _initialized : 1;

View File

@ -600,7 +600,7 @@ void EditChatAdminsBoxController::rebuildRows() {
for (auto i = _chat->participants.cbegin(), e = _chat->participants.cend(); i != e; ++i) { for (auto i = _chat->participants.cbegin(), e = _chat->participants.cend(); i != e; ++i) {
if (i.key()->id == peerFromUser(_chat->creator)) continue; 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()); admins.push_back(i.key());
} else { } else {
others.push_back(i.key()); others.push_back(i.key());

View File

@ -661,7 +661,7 @@ void ShareBox::Inner::changePeerCheckState(Chat *chat, bool checked, ChangeState
_selected.insert(chat->peer); _selected.insert(chat->peer);
setActive(chatIndex(chat->peer)); setActive(chatIndex(chat->peer));
} else { } else {
_selected.remove(chat->peer); _selected.erase(chat->peer);
} }
if (useCallback != ChangeStateWay::SkipCallback && _peerSelectedChangedCallback) { if (useCallback != ChangeStateWay::SkipCallback && _peerSelectedChangedCallback) {
_peerSelectedChangedCallback(chat->peer, checked); _peerSelectedChangedCallback(chat->peer, checked);

View File

@ -199,7 +199,7 @@ private:
using DataMap = QMap<PeerData *, Chat *>; using DataMap = QMap<PeerData *, Chat *>;
DataMap _dataMap; DataMap _dataMap;
using SelectedChats = OrderedSet<PeerData *>; using SelectedChats = std::set<PeerData *>;
SelectedChats _selected; SelectedChats _selected;
base::lambda<void(PeerData *peer, bool selected)> _peerSelectedChangedCallback; base::lambda<void(PeerData *peer, bool selected)> _peerSelectedChangedCallback;

View File

@ -277,7 +277,7 @@ void FieldAutocomplete::updateFiltered(bool resetScroll) {
cnt = _user->botInfo->commands.size(); cnt = _user->botInfo->commands.size();
bots.insert(_user, true); bots.insert(_user, true);
} else if (_channel && _channel->isMegagroup()) { } else if (_channel && _channel->isMegagroup()) {
if (_channel->mgInfo->bots.isEmpty()) { if (_channel->mgInfo->bots.empty()) {
if (!_channel->mgInfo->botStatus) { if (!_channel->mgInfo->botStatus) {
Auth().api().requestBots(_channel); Auth().api().requestBots(_channel);
} }

View File

@ -514,7 +514,7 @@ void SpecialSetReceived(quint64 setId, const QString &setTitle, const QVector<MT
} }
void FeaturedSetsReceived(const QVector<MTPStickerSetCovered> &data, const QVector<MTPlong> &unread, qint32 hash) { void FeaturedSetsReceived(const QVector<MTPStickerSetCovered> &data, const QVector<MTPlong> &unread, qint32 hash) {
OrderedSet<quint64> unreadMap; std::set<quint64> unreadMap;
for_const (auto &unreadSetId, unread) { unreadMap.insert(unreadSetId.v); } for_const (auto &unreadSetId, unread) { unreadMap.insert(unreadSetId.v); }
auto &setsOrder = Global::RefFeaturedStickerSetsOrder(); auto &setsOrder = Global::RefFeaturedStickerSetsOrder();
@ -548,7 +548,7 @@ void FeaturedSetsReceived(const QVector<MTPStickerSetCovered> &data, const QVect
auto title = GetSetTitle(*set); auto title = GetSetTitle(*set);
if (it == sets.cend()) { if (it == sets.cend()) {
auto setClientFlags = MTPDstickerSet_ClientFlag::f_featured | MTPDstickerSet_ClientFlag::f_not_loaded; 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; setClientFlags |= MTPDstickerSet_ClientFlag::f_unread;
} }
it = sets.insert(set->vid.v, Set(set->vid.v, set->vaccess_hash.v, title, qs(set->vshort_name), 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<MTPStickerSetCovered> &data, const QVect
MTPDstickerSet_ClientFlag::f_not_loaded | MTPDstickerSet_ClientFlag::f_special); MTPDstickerSet_ClientFlag::f_not_loaded | MTPDstickerSet_ClientFlag::f_special);
it->flags = set->vflags.v | clientFlags; it->flags = set->vflags.v | clientFlags;
it->flags |= MTPDstickerSet_ClientFlag::f_featured; it->flags |= MTPDstickerSet_ClientFlag::f_featured;
if (unreadMap.contains(it->id)) { if (unreadMap.find(it->id) != unreadMap.end()) {
it->flags |= MTPDstickerSet_ClientFlag::f_unread; it->flags |= MTPDstickerSet_ClientFlag::f_unread;
} else { } else {
it->flags &= ~MTPDstickerSet_ClientFlag::f_unread; it->flags &= ~MTPDstickerSet_ClientFlag::f_unread;
@ -859,7 +859,7 @@ FeaturedReader::FeaturedReader(QObject *parent)
} }
void FeaturedReader::scheduleRead(quint64 setId) { void FeaturedReader::scheduleRead(quint64 setId) {
if (!_setIds.contains(setId)) { if (_setIds.find(setId) == _setIds.end()) {
_setIds.insert(setId); _setIds.insert(setId);
_timer->start(kReadFeaturedSetsTimeoutMs); _timer->start(kReadFeaturedSetsTimeoutMs);
} }

View File

@ -59,7 +59,7 @@ private:
void readSets(); void readSets();
object_ptr<SingleTimer> _timer; object_ptr<SingleTimer> _timer;
OrderedSet<quint64> _setIds; std::set<quint64> _setIds;
}; };
} // namespace internal } // namespace internal

View File

@ -600,7 +600,7 @@ void StickersListWidget::installedLocally(quint64 setId) {
} }
void StickersListWidget::notInstalledLocally(quint64 setId) { void StickersListWidget::notInstalledLocally(quint64 setId) {
_installedLocallySets.remove(setId); _installedLocallySets.erase(setId);
} }
void StickersListWidget::clearInstalledLocally() { 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::Archived) && (it->flags & MTPDstickerSet::Flag::f_archived)) return;
if ((skip == AppendSkip::Installed) && (it->flags & MTPDstickerSet::Flag::f_installed) && if ((skip == AppendSkip::Installed) && (it->flags & MTPDstickerSet::Flag::f_installed) &&
!(it->flags & MTPDstickerSet::Flag::f_archived)) { !(it->flags & MTPDstickerSet::Flag::f_archived)) {
if (!_installedLocallySets.contains(setId)) { if (_installedLocallySets.find(setId) == _installedLocallySets.end()) {
return; return;
} }
} }

View File

@ -219,7 +219,7 @@ private:
ChannelData *_megagroupSet = nullptr; ChannelData *_megagroupSet = nullptr;
Sets _mySets; Sets _mySets;
Sets _featuredSets; Sets _featuredSets;
OrderedSet<quint64> _installedLocallySets; std::set<quint64> _installedLocallySets;
QList<bool> _custom; QList<bool> _custom;
base::flat_set<not_null<DocumentData *>> _favedStickersMap; base::flat_set<not_null<DocumentData *>> _favedStickersMap;

View File

@ -21,7 +21,6 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org
#pragma once #pragma once
#include "base/build_config.h" #include "base/build_config.h"
#include "base/ordered_set.h"
#include <QLatin1String> #include <QLatin1String>
#include <QString> #include <QString>
#include <cstdint> #include <cstdint>

View File

@ -19,13 +19,12 @@ Full license: https://github.com/telegramdesktop/tdesktop/blob/master/LICENSE
Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org
*/ */
#include "data/data_abstract_structure.h" #include "data/data_abstract_structure.h"
#include "base/ordered_set.h"
#include "core/utils.h" #include "core/utils.h"
namespace Data { namespace Data {
namespace { namespace {
using DataStructures = OrderedSet<AbstractStructure **>; using DataStructures = std::set<AbstractStructure **>;
NeverFreedPointer<DataStructures> structures; NeverFreedPointer<DataStructures> structures;
} // namespace } // namespace

View File

@ -139,7 +139,7 @@ void IndexedList::adjustByName(PeerData *peer, const PeerData::Names &oldNames,
list->del(peer->id, mainRow); list->del(peer->id, mainRow);
} }
} }
if (!toAdd.isEmpty()) { if (!toAdd.empty()) {
for_const (auto ch, toAdd) { for_const (auto ch, toAdd) {
auto j = _index.find(ch); auto j = _index.find(ch);
if (j == _index.cend()) { if (j == _index.cend()) {

View File

@ -324,7 +324,7 @@ DeclareRefVar(base::Observable<void>, PhoneCallsEnabledChanged);
typedef QMap<PeerId, MsgId> HiddenPinnedMessagesMap; typedef QMap<PeerId, MsgId> HiddenPinnedMessagesMap;
DeclareVar(HiddenPinnedMessagesMap, HiddenPinnedMessages); DeclareVar(HiddenPinnedMessagesMap, HiddenPinnedMessages);
typedef OrderedSet<HistoryItem *> PendingItemsMap; typedef std::set<HistoryItem *> PendingItemsMap;
DeclareRefVar(PendingItemsMap, PendingRepaintItems); DeclareRefVar(PendingItemsMap, PendingRepaintItems);
DeclareVar(Stickers::Sets, StickerSets); DeclareVar(Stickers::Sets, StickerSets);

View File

@ -786,7 +786,7 @@ void Histories::setIsPinned(History *history, bool isPinned) {
minIndexHistory->setPinnedDialog(false); minIndexHistory->setPinnedDialog(false);
} }
} else { } 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); Notify::peerUpdatedDelayed(peer, Notify::PeerUpdate::Flag::AdminsChanged);
} }
megagroupInfo->bots.remove(user); megagroupInfo->bots.erase(user);
if (megagroupInfo->bots.isEmpty() && megagroupInfo->botStatus > 0) { if (megagroupInfo->bots.empty() && megagroupInfo->botStatus > 0) {
megagroupInfo->botStatus = -1; megagroupInfo->botStatus = -1;
} }
} }
@ -1366,7 +1366,7 @@ HistoryItem *History::addNewItem(HistoryItem *adding, bool newMsg) {
if (adding->definesReplyKeyboard()) { if (adding->definesReplyKeyboard()) {
auto markupFlags = adding->replyKeyboardFlags(); auto markupFlags = adding->replyKeyboardFlags();
if (!(markupFlags & MTPDreplyKeyboardMarkup::Flag::f_selective) || adding->mentionsMe()) { if (!(markupFlags & MTPDreplyKeyboardMarkup::Flag::f_selective) || adding->mentionsMe()) {
auto getMarkupSenders = [this]() -> OrderedSet<not_null<PeerData *>> * { auto getMarkupSenders = [this]() -> std::set<not_null<PeerData *>> * {
if (auto chat = peer->asChat()) { if (auto chat = peer->asChat()) {
return &chat->markupSenders; return &chat->markupSenders;
} else if (auto channel = peer->asMegagroup()) { } else if (auto channel = peer->asMegagroup()) {
@ -1387,11 +1387,13 @@ HistoryItem *History::addNewItem(HistoryItem *adding, bool newMsg) {
if (peer->isChat()) { if (peer->isChat()) {
botNotInChat = adding->from()->isUser() && botNotInChat = adding->from()->isUser() &&
(!peer->canWrite() || !peer->asChat()->participants.isEmpty()) && (!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()) { } else if (peer->isMegagroup()) {
botNotInChat = adding->from()->isUser() && botNotInChat = adding->from()->isUser() &&
(!peer->canWrite() || peer->asChannel()->mgInfo->botStatus != 0) && (!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) { if (botNotInChat) {
clearLastKeyboard(); clearLastKeyboard();
@ -1525,7 +1527,7 @@ void History::addOlderSlice(const QVector<MTPMessage> &slice) {
bool channel = isChannel(); bool channel = isChannel();
qint32 mask = 0; qint32 mask = 0;
QList<not_null<UserData *>> *lastAuthors = nullptr; QList<not_null<UserData *>> *lastAuthors = nullptr;
OrderedSet<not_null<PeerData *>> *markupSenders = nullptr; std::set<not_null<PeerData *>> *markupSenders = nullptr;
if (peer->isChat()) { if (peer->isChat()) {
lastAuthors = &peer->asChat()->lastAuthors; lastAuthors = &peer->asChat()->lastAuthors;
markupSenders = &peer->asChat()->markupSenders; markupSenders = &peer->asChat()->markupSenders;
@ -1560,7 +1562,7 @@ void History::addOlderSlice(const QVector<MTPMessage> &slice) {
if (!lastKeyboardInited && item->definesReplyKeyboard() && !item->out()) { if (!lastKeyboardInited && item->definesReplyKeyboard() && !item->out()) {
auto markupFlags = item->replyKeyboardFlags(); auto markupFlags = item->replyKeyboardFlags();
if (!(markupFlags & MTPDreplyKeyboardMarkup::Flag::f_selective) || item->mentionsMe()) { if (!(markupFlags & MTPDreplyKeyboardMarkup::Flag::f_selective) || item->mentionsMe()) {
bool wasKeyboardHide = markupSenders->contains(item->author()); bool wasKeyboardHide = markupSenders->find(item->author()) != markupSenders->end();
if (!wasKeyboardHide) { if (!wasKeyboardHide) {
markupSenders->insert(item->author()); markupSenders->insert(item->author());
} }
@ -1575,7 +1577,8 @@ void History::addOlderSlice(const QVector<MTPMessage> &slice) {
botNotInChat = botNotInChat =
(!peer->canWrite() || peer->asChannel()->mgInfo->botStatus != 0) && (!peer->canWrite() || peer->asChannel()->mgInfo->botStatus != 0) &&
item->author()->isUser() && 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) { if (wasKeyboardHide || botNotInChat) {
clearLastKeyboard(); clearLastKeyboard();
@ -2232,7 +2235,7 @@ void History::clear(bool leaveItems) {
} }
if (!leaveItems) { if (!leaveItems) {
for (auto i = 0; i != OverviewCount; ++i) { for (auto i = 0; i != OverviewCount; ++i) {
if (!_overview[i].isEmpty()) { if (!_overview[i].empty()) {
_overviewCountData[i] = -1; // not loaded yet _overviewCountData[i] = -1; // not loaded yet
_overview[i].clear(); _overview[i].clear();
if (!App::quitting()) { if (!App::quitting()) {

View File

@ -108,7 +108,7 @@ private:
int _unreadFull = 0; int _unreadFull = 0;
int _unreadMuted = 0; int _unreadMuted = 0;
base::Observable<SendActionAnimationUpdate> _sendActionAnimationUpdated; base::Observable<SendActionAnimationUpdate> _sendActionAnimationUpdated;
OrderedSet<History *> _pinnedDialogs; std::set<History *> _pinnedDialogs;
base::Timer _selfDestructTimer; base::Timer _selfDestructTimer;
std::vector<FullMsgId> _selfDestructItems; std::vector<FullMsgId> _selfDestructItems;
@ -491,7 +491,7 @@ public:
} }
return result; return result;
} }
const OrderedSet<MsgId> &overview(qint32 overviewIndex) const { const std::set<MsgId> &overview(qint32 overviewIndex) const {
return _overview[overviewIndex]; return _overview[overviewIndex];
} }
MsgId overviewMinId(qint32 overviewIndex) const { MsgId overviewMinId(qint32 overviewIndex) const {
@ -499,7 +499,7 @@ public:
} }
void overviewSliceDone(qint32 overviewIndex, const MTPmessages_Messages &result, bool onlyCounts = false); void overviewSliceDone(qint32 overviewIndex, const MTPmessages_Messages &result, bool onlyCounts = false);
bool overviewHasMsgId(qint32 overviewIndex, MsgId msgId) const { 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); void changeMsgId(MsgId oldId, MsgId newId);
@ -587,7 +587,7 @@ private:
} }
quint64 _sortKeyInChatList = 0; // like ((unixtime) << 32) | (incremented counter) quint64 _sortKeyInChatList = 0; // like ((unixtime) << 32) | (incremented counter)
OrderedSet<MsgId> _overview[OverviewCount]; std::set<MsgId> _overview[OverviewCount];
qint32 _overviewCountData[OverviewCount]; // -1 - not loaded, 0 - all loaded, > 0 - count, but not all loaded 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. // A pointer to the block that is currently being built.

View File

@ -728,7 +728,7 @@ void HistoryItem::destroy() {
history()->setUnreadCount(history()->unreadCount() - 1); history()->setUnreadCount(history()->unreadCount() - 1);
} }
} }
Global::RefPendingRepaintItems().remove(this); Global::RefPendingRepaintItems().erase(this);
delete this; delete this;
} }

View File

@ -164,7 +164,7 @@ void FastShareMessage(not_null<HistoryItem *> item) {
ShareData(const FullMsgId &msgId) ShareData(const FullMsgId &msgId)
: msgId(msgId) {} : msgId(msgId) {}
FullMsgId msgId; FullMsgId msgId;
OrderedSet<mtpRequestId> requests; std::set<mtpRequestId> requests;
}; };
auto data = MakeShared<ShareData>(item->fullId()); auto data = MakeShared<ShareData>(item->fullId());
auto isGame = item->getMessageBot() && item->getMedia() && (item->getMedia()->type() == MediaTypeGame); auto isGame = item->getMessageBot() && item->getMedia() && (item->getMedia()->type() == MediaTypeGame);
@ -233,7 +233,7 @@ void FastShareMessage(not_null<HistoryItem *> item) {
if (auto main = App::main()) { if (auto main = App::main()) {
main->sentUpdatesReceived(updates); main->sentUpdatesReceived(updates);
} }
data->requests.remove(requestId); data->requests.erase(requestId);
if (data->requests.empty()) { if (data->requests.empty()) {
Ui::Toast::Show(lang(lng_share_done)); Ui::Toast::Show(lang(lng_share_done));
Ui::hideLayer(); Ui::hideLayer();

View File

@ -227,7 +227,7 @@ void unregDocumentItem(DocumentData *document, ItemBase *item) {
if (documentItemsMap) { if (documentItemsMap) {
auto i = documentItemsMap->find(document); auto i = documentItemsMap->find(document);
if (i != documentItemsMap->cend()) { if (i != documentItemsMap->cend()) {
if (i->remove(item) && i->isEmpty()) { if (i->erase(item) && i->empty()) {
documentItemsMap->erase(i); documentItemsMap->erase(i);
} }
} }

View File

@ -129,7 +129,7 @@ private:
not_null<Context *> _context; not_null<Context *> _context;
}; };
using DocumentItems = QMap<DocumentData *, OrderedSet<ItemBase *>>; using DocumentItems = QMap<DocumentData *, std::set<ItemBase *>>;
const DocumentItems *documentItems(); const DocumentItems *documentItems();
namespace internal { namespace internal {

View File

@ -64,7 +64,7 @@ private:
const char *_end = nullptr; const char *_end = nullptr;
QString _result; QString _result;
OrderedSet<ushort> _tagsUsed; std::set<ushort> _tagsUsed;
}; };
ValueParser::ValueParser(const QByteArray &key, LangKey keyIndex, const QByteArray &value) ValueParser::ValueParser(const QByteArray &key, LangKey keyIndex, const QByteArray &value)
@ -118,7 +118,7 @@ bool ValueParser::readTag() {
if (!IsTagReplaced(_keyIndex, _currentTagIndex)) { if (!IsTagReplaced(_keyIndex, _currentTagIndex)) {
return logError("Unexpected tag"); return logError("Unexpected tag");
} }
if (_tagsUsed.contains(_currentTagIndex)) { if (_tagsUsed.find(_currentTagIndex) != _tagsUsed.end()) {
return logError("Repeated tag"); return logError("Repeated tag");
} }
_tagsUsed.insert(_currentTagIndex); _tagsUsed.insert(_currentTagIndex);

View File

@ -675,7 +675,7 @@ void MainWidget::gameUpdated(GameData *data) {
void MainWidget::webPagesOrGamesUpdate() { void MainWidget::webPagesOrGamesUpdate() {
_webPageOrGameUpdater.stop(); _webPageOrGameUpdater.stop();
if (!_webPagesUpdated.isEmpty()) { if (!_webPagesUpdated.empty()) {
auto &items = App::webPageItems(); auto &items = App::webPageItems();
for_const (auto webPageId, _webPagesUpdated) { for_const (auto webPageId, _webPagesUpdated) {
auto j = items.constFind(App::webPage(webPageId)); auto j = items.constFind(App::webPage(webPageId));
@ -685,7 +685,7 @@ void MainWidget::webPagesOrGamesUpdate() {
} }
_webPagesUpdated.clear(); _webPagesUpdated.clear();
} }
if (!_gamesUpdated.isEmpty()) { if (!_gamesUpdated.empty()) {
auto &items = App::gameItems(); auto &items = App::gameItems();
for_const (auto gameId, _gamesUpdated) { for_const (auto gameId, _gamesUpdated) {
auto j = items.constFind(App::game(gameId)); auto j = items.constFind(App::game(gameId));

View File

@ -598,8 +598,8 @@ private:
not_null<Window::Controller *> _controller; not_null<Window::Controller *> _controller;
bool _started = false; bool _started = false;
OrderedSet<WebPageId> _webPagesUpdated; std::set<WebPageId> _webPagesUpdated;
OrderedSet<GameId> _gamesUpdated; std::set<GameId> _gamesUpdated;
QTimer _webPageOrGameUpdater; QTimer _webPageOrGameUpdater;
SingleTimer _updateMutedTimer; SingleTimer _updateMutedTimer;

View File

@ -428,13 +428,12 @@ void MediaView::updateControls() {
if (_photo || (_history && _overview != OverviewCount)) { if (_photo || (_history && _overview != OverviewCount)) {
_leftNavVisible = _leftNavVisible =
(_index > 0) || (_index > 0) ||
(_index == 0 && (_index == 0 && ((!_msgmigrated && _history &&
((!_msgmigrated && _history &&
_history->overview(_overview).size() < _history->overviewCount(_overview)) || _history->overview(_overview).size() < _history->overviewCount(_overview)) ||
(_msgmigrated && _migrated && (_msgmigrated && _migrated &&
_migrated->overview(_overview).size() < _migrated->overviewCount(_overview)) || _migrated->overview(_overview).size() < _migrated->overviewCount(_overview)) ||
(!_msgmigrated && _history && _migrated && (!_msgmigrated && _history && _migrated &&
(!_migrated->overview(_overview).isEmpty() || _migrated->overviewCount(_overview) > 0)))) || (!_migrated->overview(_overview).empty() || _migrated->overviewCount(_overview) > 0)))) ||
(_index < 0 && _photo == _additionalChatPhoto && (_index < 0 && _photo == _additionalChatPhoto &&
((_history && _history->overviewCount(_overview) > 0) || ((_history && _history->overviewCount(_overview) > 0) ||
(_migrated && _history->overviewLoaded(_overview) && _migrated->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 && _history && _index + 1 < _history->overview(_overview).size()) ||
(_msgmigrated && _migrated && _index + 1 < _migrated->overview(_overview).size()) || (_msgmigrated && _migrated && _index + 1 < _migrated->overview(_overview).size()) ||
(_msgmigrated && _migrated && _history && (_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() && (!_msgmigrated && _history && _index + 1 == _history->overview(_overview).size() &&
_additionalChatPhoto) || _additionalChatPhoto) ||
(_msgmigrated && _migrated && _index + 1 == _migrated->overview(_overview).size() && (_msgmigrated && _migrated && _index + 1 == _migrated->overview(_overview).size() &&
@ -2959,7 +2958,7 @@ void MediaView::loadBack() {
} else { } else {
App::main()->loadMediaBack(_history->peer, _overview); App::main()->loadMediaBack(_history->peer, _overview);
if (_migrated && _index == 0 && if (_migrated && _index == 0 &&
(_migrated->overviewCount(_overview) < 0 || _migrated->overview(_overview).isEmpty()) && (_migrated->overviewCount(_overview) < 0 || _migrated->overview(_overview).empty()) &&
!_migrated->overviewLoaded(_overview)) { !_migrated->overviewLoaded(_overview)) {
App::main()->loadMediaBack(_migrated->peer, _overview); App::main()->loadMediaBack(_migrated->peer, _overview);
} }
@ -2994,13 +2993,13 @@ MediaView::LastChatPhoto MediaView::computeLastOverviewChatPhoto() {
if (!_history) return emptyResult; if (!_history) return emptyResult;
auto &list = _history->overview(OverviewChatPhotos); auto &list = _history->overview(OverviewChatPhotos);
if (!list.isEmpty()) { if (!list.empty()) {
return lastPhotoInOverview(_history, list); return lastPhotoInOverview(_history, list);
} }
if (!_migrated || !_history->overviewLoaded(OverviewChatPhotos)) return emptyResult; if (!_migrated || !_history->overviewLoaded(OverviewChatPhotos)) return emptyResult;
auto &migratedList = _migrated->overview(OverviewChatPhotos); auto &migratedList = _migrated->overview(OverviewChatPhotos);
if (!migratedList.isEmpty()) { if (!migratedList.empty()) {
return lastPhotoInOverview(_migrated, migratedList); return lastPhotoInOverview(_migrated, migratedList);
} }
return emptyResult; return emptyResult;
@ -3058,8 +3057,8 @@ void MediaView::updateHeader() {
if (_history) { if (_history) {
if (_overview != OverviewCount) { if (_overview != OverviewCount) {
bool lastOverviewPhotoLoaded = bool lastOverviewPhotoLoaded =
(!_history->overview(_overview).isEmpty() || (!_history->overview(_overview).empty() ||
(_migrated && _history->overviewCount(_overview) == 0 && !_migrated->overview(_overview).isEmpty())); (_migrated && _history->overviewCount(_overview) == 0 && !_migrated->overview(_overview).empty()));
count = _history->overviewCount(_overview); count = _history->overviewCount(_overview);
if (addcount >= 0 && count >= 0) { if (addcount >= 0 && count >= 0) {
count += addcount; count += addcount;

View File

@ -810,8 +810,8 @@ void OverviewInner::paintEvent(QPaintEvent *e) {
auto ms = getms(); auto ms = getms();
Overview::Layout::PaintContext context(ms, _selMode); Overview::Layout::PaintContext context(ms, _selMode);
if (_history->overview(_type).isEmpty() && if (_history->overview(_type).empty() &&
(!_migrated || !_history->overviewLoaded(_type) || _migrated->overview(_type).isEmpty())) { (!_migrated || !_history->overviewLoaded(_type) || _migrated->overview(_type).empty())) {
HistoryLayout::paintEmpty(p, _width, height()); HistoryLayout::paintEmpty(p, _width, height());
return; return;
} else if (_inSearch && _searchResults.isEmpty() && _searchFull && (!_migrated || _searchFullMigrated) && } else if (_inSearch && _searchResults.isEmpty() && _searchFull && (!_migrated || _searchFullMigrated) &&
@ -1681,7 +1681,7 @@ void OverviewInner::mediaOverviewUpdated() {
auto migratedOverview = _migrated ? &_migrated->overview(_type) : nullptr; auto migratedOverview = _migrated ? &_migrated->overview(_type) : nullptr;
auto migrateCount = migratedIndexSkip(); auto migrateCount = migratedIndexSkip();
auto fullCount = (migrateCount + o.size()); auto fullCount = (migrateCount + o.size());
auto tocheck = std::min(fullCount, _itemsToBeLoaded); auto tocheck = std::min((qint32)fullCount, _itemsToBeLoaded);
_items.reserve(tocheck); _items.reserve(tocheck);
auto index = 0; auto index = 0;
@ -1723,7 +1723,7 @@ void OverviewInner::mediaOverviewUpdated() {
auto migratedOverview = _migrated ? &_migrated->overview(_type) : nullptr; auto migratedOverview = _migrated ? &_migrated->overview(_type) : nullptr;
auto migrateCount = migratedIndexSkip(); auto migrateCount = migratedIndexSkip();
auto l = _inSearch ? _searchResults.size() : (migrateCount + o.size()); 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 _items.reserve((withDates ? 2 : 1) * tocheck); // day items
auto migrateIt = migratedOverview ? migratedOverview->end() : o.end(); 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; History *m = (update.peer && update.peer->migrateFrom()) ? App::historyLoaded(update.peer->migrateFrom()->id) : 0;
if (h) { if (h) {
for (qint32 i = 0; i < OverviewCount; ++i) { 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); 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); mask |= (1 << i);
} }
} }

View File

@ -384,8 +384,8 @@ bool TranslucentWindowsSupported(QPoint globalPosition) {
return true; return true;
} }
static OrderedSet<int> WarnedAbout; static std::set<int> WarnedAbout;
if (!WarnedAbout.contains(index)) { if (WarnedAbout.find(index) == WarnedAbout.end()) {
WarnedAbout.insert(index); WarnedAbout.insert(index);
LOG(("WARNING: Compositing is disabled for screen index %1 (for position %2,%3)") LOG(("WARNING: Compositing is disabled for screen index %1 (for position %2,%3)")
.arg(index) .arg(index)

View File

@ -321,10 +321,10 @@ void GroupMembersWidget::checkSelfAdmin(ChatData *chat) {
if (chat->participants.isEmpty()) return; if (chat->participants.isEmpty()) return;
auto self = App::self(); 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); chat->admins.insert(self);
} else if (!chat->amAdmin() && chat->admins.contains(self)) { } else if (!chat->amAdmin() && (chat->admins.find(self) != chat->admins.end())) {
chat->admins.remove(self); chat->admins.erase(self);
} }
} }
@ -392,14 +392,14 @@ void GroupMembersWidget::setItemFlags(Item *item, ChatData *chat) {
using AdminState = Item::AdminState; using AdminState = Item::AdminState;
auto user = getMember(item)->user(); auto user = getMember(item)->user();
auto isCreator = (peerFromUser(chat->creator) == item->peer->id); 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; auto adminState = isCreator ? AdminState::Creator : isAdmin ? AdminState::Admin : AdminState::None;
item->adminState = adminState; item->adminState = adminState;
if (item->peer->id == Auth().userPeerId()) { if (item->peer->id == Auth().userPeerId()) {
item->hasRemoveLink = false; item->hasRemoveLink = false;
} else if (chat->amCreator() || (chat->amAdmin() && (adminState == AdminState::None))) { } else if (chat->amCreator() || (chat->amAdmin() && (adminState == AdminState::None))) {
item->hasRemoveLink = true; 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; item->hasRemoveLink = true;
} else { } else {
item->hasRemoveLink = false; item->hasRemoveLink = false;

View File

@ -1428,7 +1428,7 @@ void AddParticipantBoxSearchController::addChatsContacts() {
auto dialogsIndex = getSmallestIndex(App::main()->dialogsList()); auto dialogsIndex = getSmallestIndex(App::main()->dialogsList());
auto contactsIndex = getSmallestIndex(App::main()->contactsNoDialogsList()); auto contactsIndex = getSmallestIndex(App::main()->contactsNoDialogsList());
auto allWordsAreFound = [&wordList](const OrderedSet<QString> &names) { auto allWordsAreFound = [&wordList](const std::set<QString> &names) {
auto hasNamePartStartingWith = [&names](const QString &word) { auto hasNamePartStartingWith = [&names](const QString &word) {
for_const (auto &namePart, names) { for_const (auto &namePart, names) {
if (namePart.startsWith(word)) { if (namePart.startsWith(word)) {

View File

@ -1212,7 +1212,7 @@ void WebLoadManager::onFailed(QNetworkReply *reply) {
.arg(reply->errorString())); .arg(reply->errorString()));
if (!handleReplyResult(loader, WebReplyProcessError)) { if (!handleReplyResult(loader, WebReplyProcessError)) {
_loaders.remove(loader); _loaders.erase(loader);
delete loader; delete loader;
} }
} }
@ -1263,7 +1263,7 @@ void WebLoadManager::onProgress(qint64 already, qint64 size) {
} }
if (!handleReplyResult(loader, result)) { if (!handleReplyResult(loader, result)) {
_replies.erase(j); _replies.erase(j);
_loaders.remove(loader); _loaders.erase(loader);
delete loader; delete loader;
reply->abort(); reply->abort();
@ -1292,7 +1292,7 @@ void WebLoadManager::onMeta() {
m.captured(1).toLongLong()); m.captured(1).toLongLong());
if (!handleReplyResult(loader, WebReplyProcessProgress)) { if (!handleReplyResult(loader, WebReplyProcessProgress)) {
_replies.erase(j); _replies.erase(j);
_loaders.remove(loader); _loaders.erase(loader);
delete loader; delete loader;
reply->abort(); reply->abort();
@ -1336,7 +1336,7 @@ void WebLoadManager::process() {
} }
} }
for_const (webFileLoaderPrivate *loader, newLoaders) { for_const (webFileLoaderPrivate *loader, newLoaders) {
if (_loaders.contains(loader)) { if (_loaders.erase(loader)) {
sendRequest(loader); sendRequest(loader);
} }
} }

View File

@ -377,7 +377,7 @@ private:
LoaderPointers _loaderPointers; LoaderPointers _loaderPointers;
mutable QMutex _loaderPointersMutex; mutable QMutex _loaderPointersMutex;
typedef OrderedSet<webFileLoaderPrivate *> Loaders; typedef std::set<webFileLoaderPrivate *> Loaders;
Loaders _loaders; Loaders _loaders;
typedef QMap<QNetworkReply *, webFileLoaderPrivate *> Replies; typedef QMap<QNetworkReply *, webFileLoaderPrivate *> Replies;

View File

@ -625,7 +625,7 @@ WebFilesMap _webFilesMap;
quint64 _storageWebFilesSize = 0; quint64 _storageWebFilesSize = 0;
FileKey _locationsKey = 0, _reportSpamStatusesKey = 0, _trustedBotsKey = 0; FileKey _locationsKey = 0, _reportSpamStatusesKey = 0, _trustedBotsKey = 0;
using TrustedBots = OrderedSet<quint64>; using TrustedBots = std::set<quint64>;
TrustedBots _trustedBots; TrustedBots _trustedBots;
bool _trustedBotsRead = false; bool _trustedBotsRead = false;
@ -3451,12 +3451,12 @@ void _readStickerSets(FileKey &stickersKey, Stickers::Order *outOrder = nullptr,
} }
Serialize::Document::StickerSetInfo info(setId, setAccess, setShortName); Serialize::Document::StickerSetInfo info(setId, setAccess, setShortName);
OrderedSet<DocumentId> read; std::set<DocumentId> read;
for (qint32 j = 0; j < scnt; ++j) { for (qint32 j = 0; j < scnt; ++j) {
auto document = Serialize::Document::readStickerFromStream(stickers.version, stickers.stream, info); auto document = Serialize::Document::readStickerFromStream(stickers.version, stickers.stream, info);
if (!document || !document->sticker()) continue; if (!document || !document->sticker()) continue;
if (read.contains(document->id)) continue; if (read.find(document->id) != read.end()) continue;
read.insert(document->id); read.insert(document->id);
if (fillStickers) { if (fillStickers) {
@ -3838,12 +3838,12 @@ void readSavedGifs() {
quint32 cnt; quint32 cnt;
gifs.stream >> cnt; gifs.stream >> cnt;
saved.reserve(cnt); saved.reserve(cnt);
OrderedSet<DocumentId> read; std::set<DocumentId> read;
for (quint32 i = 0; i < cnt; ++i) { for (quint32 i = 0; i < cnt; ++i) {
auto document = Serialize::Document::readFromStream(gifs.version, gifs.stream); auto document = Serialize::Document::readFromStream(gifs.version, gifs.stream);
if (!document || !document->isGifv()) continue; if (!document || !document->isGifv()) continue;
if (read.contains(document->id)) continue; if (read.find(document->id) != read.end()) continue;
read.insert(document->id); read.insert(document->id);
saved.push_back(document); saved.push_back(document);
@ -4462,7 +4462,7 @@ void writeReportSpamStatuses() {
void writeTrustedBots() { void writeTrustedBots() {
if (!_working()) return; if (!_working()) return;
if (_trustedBots.isEmpty()) { if (_trustedBots.empty()) {
if (_trustedBotsKey) { if (_trustedBotsKey) {
clearKey(_trustedBotsKey); clearKey(_trustedBotsKey);
_trustedBotsKey = 0; _trustedBotsKey = 0;
@ -4517,7 +4517,7 @@ bool isBotTrusted(UserData *bot) {
readTrustedBots(); readTrustedBots();
_trustedBotsRead = true; _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) { bool encrypt(const void *src, void *dst, quint32 len, const void *key128) {

View File

@ -795,7 +795,7 @@ void ChannelData::applyEditAdmin(not_null<UserData *> user, const MTPChannelAdmi
if (!mgInfo->lastParticipants.contains(user)) { // If rights are empty - still add participant? TODO check if (!mgInfo->lastParticipants.contains(user)) { // If rights are empty - still add participant? TODO check
mgInfo->lastParticipants.push_front(user); mgInfo->lastParticipants.push_front(user);
setMembersCount(membersCount() + 1); setMembersCount(membersCount() + 1);
if (user->botInfo && !mgInfo->bots.contains(user)) { if (user->botInfo && mgInfo->bots.find(user) == mgInfo->bots.end()) {
mgInfo->bots.insert(user); mgInfo->bots.insert(user);
if (mgInfo->botStatus != 0 && mgInfo->botStatus < 2) { if (mgInfo->botStatus != 0 && mgInfo->botStatus < 2) {
mgInfo->botStatus = 2; mgInfo->botStatus = 2;
@ -885,9 +885,9 @@ void ChannelData::applyEditBanned(not_null<UserData *> user, const MTPChannelBan
mgInfo->lastParticipantsCount = 0; mgInfo->lastParticipantsCount = 0;
} }
setKickedCount(kickedCount() + 1); setKickedCount(kickedCount() + 1);
if (mgInfo->bots.contains(user)) { if (mgInfo->bots.find(user) != mgInfo->bots.end()) {
mgInfo->bots.remove(user); mgInfo->bots.erase(user);
if (mgInfo->bots.isEmpty() && mgInfo->botStatus > 0) { if (mgInfo->bots.empty() && mgInfo->botStatus > 0) {
mgInfo->botStatus = -1; mgInfo->botStatus = -1;
} }
} }

View File

@ -358,9 +358,9 @@ public:
QString name; QString name;
Text nameText; Text nameText;
using Names = OrderedSet<QString>; using Names = std::set<QString>;
Names names; // for filtering Names names; // for filtering
using NameFirstChars = OrderedSet<QChar>; using NameFirstChars = std::set<QChar>;
NameFirstChars chars; NameFirstChars chars;
enum LoadedStatus { enum LoadedStatus {
@ -651,10 +651,10 @@ public:
return flags & MTPDchat::Flag::f_migrated_to; return flags & MTPDchat::Flag::f_migrated_to;
} }
QMap<not_null<UserData *>, int> participants; QMap<not_null<UserData *>, int> participants;
OrderedSet<not_null<UserData *>> invitedByMe; std::set<not_null<UserData *>> invitedByMe;
OrderedSet<not_null<UserData *>> admins; std::set<not_null<UserData *>> admins;
QList<not_null<UserData *>> lastAuthors; QList<not_null<UserData *>> lastAuthors;
OrderedSet<not_null<PeerData *>> markupSenders; std::set<not_null<PeerData *>> markupSenders;
int botStatus = 0; // -1 - no bots, 0 - unknown, 1 - one bot, that sees all history, 2 - other int botStatus = 0; // -1 - no bots, 0 - unknown, 1 - one bot, that sees all history, 2 - other
// ImagePtr photoFull; // ImagePtr photoFull;
@ -750,8 +750,8 @@ struct MegagroupInfo {
QList<not_null<UserData *>> lastParticipants; QList<not_null<UserData *>> lastParticipants;
QMap<not_null<UserData *>, Admin> lastAdmins; QMap<not_null<UserData *>, Admin> lastAdmins;
QMap<not_null<UserData *>, Restricted> lastRestricted; QMap<not_null<UserData *>, Restricted> lastRestricted;
OrderedSet<not_null<PeerData *>> markupSenders; std::set<not_null<PeerData *>> markupSenders;
OrderedSet<not_null<UserData *>> bots; std::set<not_null<UserData *>> bots;
UserData *creator = nullptr; // nullptr means unknown UserData *creator = nullptr; // nullptr means unknown
int botStatus = 0; // -1 - no bots, 0 - unknown, 1 - one bot, that sees all history, 2 - other int botStatus = 0; // -1 - no bots, 0 - unknown, 1 - one bot, that sees all history, 2 - other

View File

@ -138,11 +138,11 @@ AnimationManager::AnimationManager()
void AnimationManager::start(BasicAnimation *obj) { void AnimationManager::start(BasicAnimation *obj) {
if (_iterating) { if (_iterating) {
_starting.insert(obj); _starting.insert(obj);
if (!_stopping.isEmpty()) { if (!_stopping.empty()) {
_stopping.remove(obj); _stopping.erase(obj);
} }
} else { } else {
if (_objects.isEmpty()) { if (_objects.empty()) {
_timer.start(AnimationTimerDelta); _timer.start(AnimationTimerDelta);
} }
_objects.insert(obj); _objects.insert(obj);
@ -152,8 +152,8 @@ void AnimationManager::start(BasicAnimation *obj) {
void AnimationManager::stop(BasicAnimation *obj) { void AnimationManager::stop(BasicAnimation *obj) {
if (_iterating) { if (_iterating) {
_stopping.insert(obj); _stopping.insert(obj);
if (!_starting.isEmpty()) { if (!_starting.empty()) {
_starting.remove(obj); _starting.erase(obj);
} }
} else { } else {
auto i = _objects.find(obj); auto i = _objects.find(obj);
@ -170,18 +170,18 @@ void AnimationManager::timeout() {
_iterating = true; _iterating = true;
auto ms = getms(); auto ms = getms();
for_const (auto object, _objects) { for_const (auto object, _objects) {
if (!_stopping.contains(object)) { if (_stopping.find(object) == _stopping.end()) {
object->step(ms, true); object->step(ms, true);
} }
} }
_iterating = false; _iterating = false;
if (!_starting.isEmpty()) { if (!_starting.empty()) {
for_const (auto object, _starting) { _objects.insert(object); } for_const (auto object, _starting) { _objects.insert(object); }
_starting.clear(); _starting.clear();
} }
if (!_stopping.isEmpty()) { if (!_stopping.empty()) {
for_const (auto object, _stopping) { _objects.remove(object); } for_const (auto object, _stopping) { _objects.erase(object); }
_stopping.clear(); _stopping.clear();
} }
if (_objects.empty()) { if (_objects.empty()) {

View File

@ -710,7 +710,7 @@ public slots:
void clipCallback(Media::Clip::Reader *reader, qint32 threadIndex, qint32 notification); void clipCallback(Media::Clip::Reader *reader, qint32 threadIndex, qint32 notification);
private: private:
using AnimatingObjects = OrderedSet<BasicAnimation *>; using AnimatingObjects = std::set<BasicAnimation *>;
AnimatingObjects _objects, _starting, _stopping; AnimatingObjects _objects, _starting, _stopping;
QTimer _timer; QTimer _timer;
bool _iterating; bool _iterating;

View File

@ -35,7 +35,7 @@ quint32 colorKey(QColor c) {
using IconMasks = QMap<const IconMask *, QImage>; using IconMasks = QMap<const IconMask *, QImage>;
using IconPixmaps = QMap<QPair<const IconMask *, quint32>, QPixmap>; using IconPixmaps = QMap<QPair<const IconMask *, quint32>, QPixmap>;
using IconDatas = OrderedSet<IconData *>; using IconDatas = std::set<IconData *>;
NeverFreedPointer<IconMasks> iconMasks; NeverFreedPointer<IconMasks> iconMasks;
NeverFreedPointer<IconPixmaps> iconPixmaps; NeverFreedPointer<IconPixmaps> iconPixmaps;
NeverFreedPointer<IconDatas> iconData; NeverFreedPointer<IconDatas> iconData;

View File

@ -58,7 +58,7 @@ private:
QMultiMap<TimeMs, Instance *> _toastByHideTime; QMultiMap<TimeMs, Instance *> _toastByHideTime;
QMap<Widget *, Instance *> _toastByWidget; QMap<Widget *, Instance *> _toastByWidget;
QList<Instance *> _toasts; QList<Instance *> _toasts;
OrderedSet<QPointer<QWidget>> _toastParents; std::set<QPointer<QWidget>> _toastParents;
}; };
} // namespace internal } // namespace internal

View File

@ -158,7 +158,7 @@ bool isValidColorValue(QLatin1String value) {
} }
QByteArray replaceValueInContent(const QByteArray &content, const QByteArray &name, const QByteArray &value) { QByteArray replaceValueInContent(const QByteArray &content, const QByteArray &name, const QByteArray &value) {
auto validNames = OrderedSet<QLatin1String>(); auto validNames = std::set<QLatin1String>();
auto start = content.constBegin(), data = start, end = data + content.size(); auto start = content.constBegin(), data = start, end = data + content.size();
auto lastValidValueStart = end, lastValidValueEnd = end; auto lastValidValueStart = end, lastValidValueEnd = end;
while (data != end) { while (data != end) {
@ -178,7 +178,7 @@ QByteArray replaceValueInContent(const QByteArray &content, const QByteArray &na
if (value.size() == 0) { if (value.size() == 0) {
return "error"; return "error";
} }
auto validValue = validNames.contains(value) || isValidColorValue(value); auto validValue = validNames.find(value) != validNames.end() || isValidColorValue(value);
if (validValue) { if (validValue) {
validNames.insert(foundName); validNames.insert(foundName);
if (foundName == name) { if (foundName == name) {

View File

@ -69,7 +69,7 @@ public:
fillSearchIndex(); fillSearchIndex();
} }
const OrderedSet<QString> &searchWords() const { const std::set<QString> &searchWords() const {
return _searchWords; return _searchWords;
} }
bool searchWordsContain(const QString &needle) const { bool searchWordsContain(const QString &needle) const {
@ -81,7 +81,7 @@ public:
return false; return false;
} }
const OrderedSet<QChar> &searchStartChars() const { const std::set<QChar> &searchStartChars() const {
return _searchStartChars; return _searchStartChars;
} }
@ -120,8 +120,8 @@ private:
QString _valueString; QString _valueString;
Text _description = {st::windowMinWidth / 2}; Text _description = {st::windowMinWidth / 2};
OrderedSet<QString> _searchWords; std::set<QString> _searchWords;
OrderedSet<QChar> _searchStartChars; std::set<QChar> _searchStartChars;
int _top = 0; int _top = 0;
int _height = 0; int _height = 0;
@ -281,8 +281,8 @@ void EditorBlock::removeFromSearch(const Row &row) {
for_const (auto ch, row.searchStartChars()) { for_const (auto ch, row.searchStartChars()) {
auto it = _searchIndex.find(ch); auto it = _searchIndex.find(ch);
if (it != _searchIndex.cend()) { if (it != _searchIndex.cend()) {
it->remove(index); it->erase(index);
if (it->isEmpty()) { if (it->empty()) {
_searchIndex.erase(it); _searchIndex.erase(it);
} }
} }
@ -356,19 +356,19 @@ void EditorBlock::searchByQuery(QString query) {
_searchQuery = query; _searchQuery = query;
_searchResults.clear(); _searchResults.clear();
auto toFilter = OrderedSet<int>(); auto toFilter = std::set<int>();
for_const (auto &word, words) { for_const (auto &word, words) {
if (word.isEmpty()) continue; if (word.isEmpty()) continue;
auto testToFilter = _searchIndex.value(word[0]); auto testToFilter = _searchIndex.value(word[0]);
if (testToFilter.isEmpty()) { if (testToFilter.empty()) {
toFilter.clear(); toFilter.clear();
break; break;
} else if (toFilter.isEmpty() || testToFilter.size() < toFilter.size()) { } else if (toFilter.empty() || testToFilter.size() < toFilter.size()) {
toFilter = testToFilter; toFilter = testToFilter;
} }
} }
if (!toFilter.isEmpty()) { if (!toFilter.empty()) {
auto allWordsFound = [&words](const Row &row) { auto allWordsFound = [&words](const Row &row) {
for_const (auto &word, words) { for_const (auto &word, words) {
if (!row.searchWordsContain(word)) { if (!row.searchWordsContain(word)) {

View File

@ -153,7 +153,7 @@ private:
QString _searchQuery; QString _searchQuery;
QVector<int> _searchResults; QVector<int> _searchResults;
QMap<QChar, OrderedSet<int>> _searchIndex; QMap<QChar, std::set<int>> _searchIndex;
int _selected = -1; int _selected = -1;
int _pressed = -1; int _pressed = -1;