2
0
mirror of https://github.com/kotatogram/kotatogram-desktop synced 2025-08-31 06:35:14 +00:00

Use base::flat_map for pointer keys

This commit is contained in:
Ilya Fedin
2021-03-15 19:22:32 +04:00
committed by John Preston
parent cdf0512515
commit 4ffe1d3acc
4 changed files with 22 additions and 22 deletions

View File

@@ -436,7 +436,7 @@ void FieldAutocomplete::updateFiltered(bool resetScroll) {
} else if (_type == Type::BotCommands) {
bool listAllSuggestions = _filter.isEmpty();
bool hasUsername = _filter.indexOf('@') > 0;
QMap<UserData*, bool> bots;
base::flat_map<UserData*, bool> bots;
int32 cnt = 0;
if (_chat) {
if (_chat->noParticipantInfo()) {
@@ -451,7 +451,7 @@ void FieldAutocomplete::updateFiltered(bool resetScroll) {
if (user->botInfo->commands.isEmpty()) {
continue;
}
bots.insert(user, true);
bots.emplace(user, true);
cnt += user->botInfo->commands.size();
}
}
@@ -460,7 +460,7 @@ void FieldAutocomplete::updateFiltered(bool resetScroll) {
_user->session().api().requestFullPeer(_user);
}
cnt = _user->botInfo->commands.size();
bots.insert(_user, true);
bots.emplace(_user, true);
} else if (_channel && _channel->isMegagroup()) {
if (_channel->mgInfo->bots.empty()) {
if (!_channel->mgInfo->botStatus) {
@@ -476,7 +476,7 @@ void FieldAutocomplete::updateFiltered(bool resetScroll) {
if (user->botInfo->commands.isEmpty()) {
continue;
}
bots.insert(user, true);
bots.emplace(user, true);
cnt += user->botInfo->commands.size();
}
}
@@ -510,9 +510,9 @@ void FieldAutocomplete::updateFiltered(bool resetScroll) {
}
}
}
if (!bots.isEmpty()) {
for (QMap<UserData*, bool>::const_iterator i = bots.cbegin(), e = bots.cend(); i != e; ++i) {
UserData *user = i.key();
if (!bots.empty()) {
for (auto i = bots.cbegin(), e = bots.cend(); i != e; ++i) {
UserData *user = i->first;
for (int32 j = 0, l = user->botInfo->commands.size(); j < l; ++j) {
if (!listAllSuggestions) {
QString toFilter = (hasUsername || botStatus == 0 || botStatus == 2) ? user->botInfo->commands.at(j).command + '@' + user->username : user->botInfo->commands.at(j).command;