Inline treap_find_message.
This commit is contained in:
parent
453a53c953
commit
316ba04a47
@ -16498,7 +16498,7 @@ unique_ptr<MessagesManager::Message> MessagesManager::do_delete_message(Dialog *
|
|||||||
CHECK(m == result.get());
|
CHECK(m == result.get());
|
||||||
d->messages.erase(message_id);
|
d->messages.erase(message_id);
|
||||||
|
|
||||||
treap_delete_message(treap_find_message(&d->ordered_messages, message_id));
|
treap_delete_message(&d->ordered_messages, message_id);
|
||||||
|
|
||||||
d->being_deleted_message_id = MessageId();
|
d->being_deleted_message_id = MessageId();
|
||||||
|
|
||||||
@ -34220,20 +34220,6 @@ void MessagesManager::unpin_all_dialog_messages_on_server(DialogId dialog_id, ui
|
|||||||
get_erase_log_event_promise(log_event_id, std::move(promise)));
|
get_erase_log_event_promise(log_event_id, std::move(promise)));
|
||||||
}
|
}
|
||||||
|
|
||||||
unique_ptr<MessagesManager::OrderedMessage> *MessagesManager::treap_find_message(unique_ptr<OrderedMessage> *v,
|
|
||||||
MessageId message_id) {
|
|
||||||
while (*v != nullptr) {
|
|
||||||
if ((*v)->message_id.get() < message_id.get()) {
|
|
||||||
v = &(*v)->right;
|
|
||||||
} else if ((*v)->message_id.get() > message_id.get()) {
|
|
||||||
v = &(*v)->left;
|
|
||||||
} else {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return v;
|
|
||||||
}
|
|
||||||
|
|
||||||
MessagesManager::OrderedMessage *MessagesManager::treap_insert_message(unique_ptr<OrderedMessage> *v,
|
MessagesManager::OrderedMessage *MessagesManager::treap_insert_message(unique_ptr<OrderedMessage> *v,
|
||||||
unique_ptr<OrderedMessage> message) {
|
unique_ptr<OrderedMessage> message) {
|
||||||
auto message_id = message->message_id;
|
auto message_id = message->message_id;
|
||||||
@ -34268,7 +34254,17 @@ MessagesManager::OrderedMessage *MessagesManager::treap_insert_message(unique_pt
|
|||||||
return v->get();
|
return v->get();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MessagesManager::treap_delete_message(unique_ptr<OrderedMessage> *v) {
|
void MessagesManager::treap_delete_message(unique_ptr<OrderedMessage> *v, MessageId message_id) {
|
||||||
|
while (*v != nullptr) {
|
||||||
|
if ((*v)->message_id.get() < message_id.get()) {
|
||||||
|
v = &(*v)->right;
|
||||||
|
} else if ((*v)->message_id.get() > message_id.get()) {
|
||||||
|
v = &(*v)->left;
|
||||||
|
} else {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
unique_ptr<OrderedMessage> result = std::move(*v);
|
unique_ptr<OrderedMessage> result = std::move(*v);
|
||||||
CHECK(result != nullptr);
|
CHECK(result != nullptr);
|
||||||
unique_ptr<OrderedMessage> left = std::move(result->left);
|
unique_ptr<OrderedMessage> left = std::move(result->left);
|
||||||
|
@ -2867,11 +2867,9 @@ class MessagesManager final : public Actor {
|
|||||||
DialogFolder *get_dialog_folder(FolderId folder_id);
|
DialogFolder *get_dialog_folder(FolderId folder_id);
|
||||||
const DialogFolder *get_dialog_folder(FolderId folder_id) const;
|
const DialogFolder *get_dialog_folder(FolderId folder_id) const;
|
||||||
|
|
||||||
static unique_ptr<OrderedMessage> *treap_find_message(unique_ptr<OrderedMessage> *v, MessageId message_id);
|
|
||||||
|
|
||||||
static OrderedMessage *treap_insert_message(unique_ptr<OrderedMessage> *v, unique_ptr<OrderedMessage> message);
|
static OrderedMessage *treap_insert_message(unique_ptr<OrderedMessage> *v, unique_ptr<OrderedMessage> message);
|
||||||
|
|
||||||
static void treap_delete_message(unique_ptr<OrderedMessage> *v);
|
static void treap_delete_message(unique_ptr<OrderedMessage> *v, MessageId message_id);
|
||||||
|
|
||||||
static Message *get_message(Dialog *d, MessageId message_id);
|
static Message *get_message(Dialog *d, MessageId message_id);
|
||||||
static const Message *get_message(const Dialog *d, MessageId message_id);
|
static const Message *get_message(const Dialog *d, MessageId message_id);
|
||||||
|
Loading…
Reference in New Issue
Block a user