Add OrderedMessages::find_older_messages.
This commit is contained in:
parent
2ff3233115
commit
2e0cba4eea
@ -11625,21 +11625,6 @@ vector<MessageId> MessagesManager::find_dialog_messages(const Dialog *d,
|
|||||||
return message_ids;
|
return message_ids;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MessagesManager::find_old_messages(const OrderedMessage *ordered_message, MessageId max_message_id,
|
|
||||||
vector<MessageId> &message_ids) {
|
|
||||||
if (ordered_message == nullptr) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
find_old_messages(ordered_message->left.get(), max_message_id, message_ids);
|
|
||||||
|
|
||||||
if (ordered_message->message_id <= max_message_id) {
|
|
||||||
message_ids.push_back(ordered_message->message_id);
|
|
||||||
|
|
||||||
find_old_messages(ordered_message->right.get(), max_message_id, message_ids);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void MessagesManager::find_newer_messages(const OrderedMessage *ordered_message, MessageId min_message_id,
|
void MessagesManager::find_newer_messages(const OrderedMessage *ordered_message, MessageId min_message_id,
|
||||||
vector<MessageId> &message_ids) {
|
vector<MessageId> &message_ids) {
|
||||||
if (ordered_message == nullptr) {
|
if (ordered_message == nullptr) {
|
||||||
@ -13072,8 +13057,7 @@ void MessagesManager::set_dialog_max_unavailable_message_id(DialogId dialog_id,
|
|||||||
|
|
||||||
d->max_unavailable_message_id = max_unavailable_message_id;
|
d->max_unavailable_message_id = max_unavailable_message_id;
|
||||||
|
|
||||||
vector<MessageId> message_ids;
|
auto message_ids = d->ordered_messages.find_older_messages(max_unavailable_message_id);
|
||||||
find_old_messages(d->ordered_messages.messages_.get(), max_unavailable_message_id, message_ids);
|
|
||||||
|
|
||||||
vector<int64> deleted_message_ids;
|
vector<int64> deleted_message_ids;
|
||||||
bool need_update_dialog_pos = false;
|
bool need_update_dialog_pos = false;
|
||||||
|
@ -2185,9 +2185,6 @@ class MessagesManager final : public Actor {
|
|||||||
static void find_messages_by_date(const Dialog *d, const OrderedMessage *ordered_message, int32 min_date,
|
static void find_messages_by_date(const Dialog *d, const OrderedMessage *ordered_message, int32 min_date,
|
||||||
int32 max_date, vector<MessageId> &message_ids);
|
int32 max_date, vector<MessageId> &message_ids);
|
||||||
|
|
||||||
static void find_old_messages(const OrderedMessage *ordered_message, MessageId max_message_id,
|
|
||||||
vector<MessageId> &message_ids);
|
|
||||||
|
|
||||||
static void find_newer_messages(const OrderedMessage *ordered_message, MessageId min_message_id,
|
static void find_newer_messages(const OrderedMessage *ordered_message, MessageId min_message_id,
|
||||||
vector<MessageId> &message_ids);
|
vector<MessageId> &message_ids);
|
||||||
|
|
||||||
|
@ -77,4 +77,25 @@ void OrderedMessages::erase(MessageId message_id) {
|
|||||||
CHECK(*v == nullptr);
|
CHECK(*v == nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void do_find_older_messages(const OrderedMessage *ordered_message, MessageId max_message_id,
|
||||||
|
vector<MessageId> &message_ids) {
|
||||||
|
if (ordered_message == nullptr) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
do_find_older_messages(ordered_message->left.get(), max_message_id, message_ids);
|
||||||
|
|
||||||
|
if (ordered_message->message_id <= max_message_id) {
|
||||||
|
message_ids.push_back(ordered_message->message_id);
|
||||||
|
|
||||||
|
do_find_older_messages(ordered_message->right.get(), max_message_id, message_ids);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
vector<MessageId> OrderedMessages::find_older_messages(MessageId max_message_id) const {
|
||||||
|
vector<MessageId> message_ids;
|
||||||
|
do_find_older_messages(messages_.get(), max_message_id, message_ids);
|
||||||
|
return message_ids;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace td
|
} // namespace td
|
||||||
|
@ -30,6 +30,8 @@ struct OrderedMessages {
|
|||||||
OrderedMessage *insert(MessageId message_id);
|
OrderedMessage *insert(MessageId message_id);
|
||||||
|
|
||||||
void erase(MessageId message_id);
|
void erase(MessageId message_id);
|
||||||
|
|
||||||
|
vector<MessageId> find_older_messages(MessageId max_message_id) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace td
|
} // namespace td
|
||||||
|
Loading…
Reference in New Issue
Block a user