Inline create_ordered_message.
This commit is contained in:
parent
316ba04a47
commit
df626f266e
@ -34221,9 +34221,9 @@ void MessagesManager::unpin_all_dialog_messages_on_server(DialogId dialog_id, ui
|
|||||||
}
|
}
|
||||||
|
|
||||||
MessagesManager::OrderedMessage *MessagesManager::treap_insert_message(unique_ptr<OrderedMessage> *v,
|
MessagesManager::OrderedMessage *MessagesManager::treap_insert_message(unique_ptr<OrderedMessage> *v,
|
||||||
unique_ptr<OrderedMessage> message) {
|
MessageId message_id) {
|
||||||
auto message_id = message->message_id;
|
auto random_y = static_cast<int32>(static_cast<uint32>(message_id.get() * 2101234567u));
|
||||||
while (*v != nullptr && (*v)->random_y >= message->random_y) {
|
while (*v != nullptr && (*v)->random_y >= random_y) {
|
||||||
if ((*v)->message_id.get() < message_id.get()) {
|
if ((*v)->message_id.get() < message_id.get()) {
|
||||||
v = &(*v)->right;
|
v = &(*v)->right;
|
||||||
} else if ((*v)->message_id == message_id) {
|
} else if ((*v)->message_id == message_id) {
|
||||||
@ -34233,6 +34233,10 @@ MessagesManager::OrderedMessage *MessagesManager::treap_insert_message(unique_pt
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
auto message = make_unique<OrderedMessage>();
|
||||||
|
message->message_id = message_id;
|
||||||
|
message->random_y = random_y;
|
||||||
|
|
||||||
unique_ptr<OrderedMessage> *left = &message->left;
|
unique_ptr<OrderedMessage> *left = &message->left;
|
||||||
unique_ptr<OrderedMessage> *right = &message->right;
|
unique_ptr<OrderedMessage> *right = &message->right;
|
||||||
|
|
||||||
@ -34438,13 +34442,6 @@ MessagesManager::Message *MessagesManager::on_get_message_from_database(Dialog *
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
unique_ptr<MessagesManager::OrderedMessage> MessagesManager::create_ordered_message(MessageId message_id) {
|
|
||||||
auto result = make_unique<OrderedMessage>();
|
|
||||||
result->message_id = message_id;
|
|
||||||
result->random_y = static_cast<int32>(static_cast<uint32>(message_id.get() * 2101234567u));
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
MessagesManager::Message *MessagesManager::add_message_to_dialog(DialogId dialog_id, unique_ptr<Message> message,
|
MessagesManager::Message *MessagesManager::add_message_to_dialog(DialogId dialog_id, unique_ptr<Message> message,
|
||||||
bool have_previous, bool have_next, bool from_update,
|
bool have_previous, bool have_next, bool from_update,
|
||||||
bool *need_update, bool *need_update_dialog_pos,
|
bool *need_update, bool *need_update_dialog_pos,
|
||||||
@ -35234,7 +35231,7 @@ MessagesManager::Message *MessagesManager::add_message_to_dialog(Dialog *d, uniq
|
|||||||
Message *result_message = message.get();
|
Message *result_message = message.get();
|
||||||
d->messages.set(message_id, std::move(message));
|
d->messages.set(message_id, std::move(message));
|
||||||
|
|
||||||
OrderedMessage *ordered_message = treap_insert_message(&d->ordered_messages, create_ordered_message(message_id));
|
OrderedMessage *ordered_message = treap_insert_message(&d->ordered_messages, message_id);
|
||||||
if (!is_attached) {
|
if (!is_attached) {
|
||||||
if (have_next) {
|
if (have_next) {
|
||||||
CHECK(!have_previous);
|
CHECK(!have_previous);
|
||||||
|
@ -2335,8 +2335,6 @@ class MessagesManager final : public Actor {
|
|||||||
|
|
||||||
void on_get_scheduled_messages_from_database(DialogId dialog_id, vector<MessageDbDialogMessage> &&messages);
|
void on_get_scheduled_messages_from_database(DialogId dialog_id, vector<MessageDbDialogMessage> &&messages);
|
||||||
|
|
||||||
static unique_ptr<OrderedMessage> create_ordered_message(MessageId message_id);
|
|
||||||
|
|
||||||
static bool have_dialog_scheduled_messages_in_memory(const Dialog *d);
|
static bool have_dialog_scheduled_messages_in_memory(const Dialog *d);
|
||||||
|
|
||||||
static bool is_allowed_useless_update(const tl_object_ptr<telegram_api::Update> &update);
|
static bool is_allowed_useless_update(const tl_object_ptr<telegram_api::Update> &update);
|
||||||
@ -2867,7 +2865,7 @@ 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 OrderedMessage *treap_insert_message(unique_ptr<OrderedMessage> *v, unique_ptr<OrderedMessage> message);
|
static OrderedMessage *treap_insert_message(unique_ptr<OrderedMessage> *v, MessageId message_id);
|
||||||
|
|
||||||
static void treap_delete_message(unique_ptr<OrderedMessage> *v, MessageId message_id);
|
static void treap_delete_message(unique_ptr<OrderedMessage> *v, MessageId message_id);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user