Use add_to_top if possible.
This commit is contained in:
parent
14b10c7682
commit
b41a51f2ec
@ -312,12 +312,8 @@ void add_recent_emoji_status(Td *td, EmojiStatus emoji_status) {
|
||||
}
|
||||
|
||||
statuses.hash_ = 0;
|
||||
td::remove(statuses.emoji_statuses_, emoji_status);
|
||||
statuses.emoji_statuses_.insert(statuses.emoji_statuses_.begin(), emoji_status);
|
||||
constexpr size_t MAX_RECENT_EMOJI_STATUSES = 50; // server-side limit
|
||||
if (statuses.emoji_statuses_.size() > MAX_RECENT_EMOJI_STATUSES) {
|
||||
statuses.emoji_statuses_.resize(MAX_RECENT_EMOJI_STATUSES);
|
||||
}
|
||||
add_to_top(statuses.emoji_statuses_, MAX_RECENT_EMOJI_STATUSES, emoji_status);
|
||||
save_emoji_statuses(get_recent_emoji_statuses_database_key(), statuses);
|
||||
}
|
||||
|
||||
|
@ -300,11 +300,7 @@ MessageReaction::MessageReaction(ReactionType reaction_type, int32 choose_count,
|
||||
void MessageReaction::add_recent_chooser_dialog_id(DialogId dialog_id) {
|
||||
CHECK(!my_recent_chooser_dialog_id_.is_valid());
|
||||
my_recent_chooser_dialog_id_ = dialog_id;
|
||||
recent_chooser_dialog_ids_.insert(recent_chooser_dialog_ids_.begin(), dialog_id);
|
||||
if (recent_chooser_dialog_ids_.size() > MAX_RECENT_CHOOSERS + 1) {
|
||||
LOG(ERROR) << "Have " << recent_chooser_dialog_ids_.size() << " recent reaction choosers";
|
||||
recent_chooser_dialog_ids_.resize(MAX_RECENT_CHOOSERS + 1);
|
||||
}
|
||||
add_to_top(recent_chooser_dialog_ids_, MAX_RECENT_CHOOSERS + 1, dialog_id);
|
||||
}
|
||||
|
||||
bool MessageReaction::remove_recent_chooser_dialog_id() {
|
||||
|
@ -166,13 +166,10 @@ bool MessageReplyInfo::add_reply(DialogId replier_dialog_id, MessageId reply_mes
|
||||
}
|
||||
}
|
||||
|
||||
td::remove(recent_replier_dialog_ids_, replier_dialog_id);
|
||||
if (diff > 0) {
|
||||
recent_replier_dialog_ids_.insert(recent_replier_dialog_ids_.begin(), replier_dialog_id);
|
||||
if (recent_replier_dialog_ids_.size() > MAX_RECENT_REPLIERS) {
|
||||
recent_replier_dialog_ids_.pop_back();
|
||||
}
|
||||
add_to_top(recent_replier_dialog_ids_, MAX_RECENT_REPLIERS, replier_dialog_id);
|
||||
} else {
|
||||
td::remove(recent_replier_dialog_ids_, replier_dialog_id);
|
||||
auto max_repliers = static_cast<size_t>(reply_count_);
|
||||
if (recent_replier_dialog_ids_.size() > max_repliers) {
|
||||
recent_replier_dialog_ids_.resize(max_repliers);
|
||||
|
Loading…
x
Reference in New Issue
Block a user