diff --git a/td/telegram/logevent/SecretChatEvent.h b/td/telegram/logevent/SecretChatEvent.h index 7b365a7c5..698e4d39b 100644 --- a/td/telegram/logevent/SecretChatEvent.h +++ b/td/telegram/logevent/SecretChatEvent.h @@ -322,7 +322,7 @@ class OutboundSecretMessage : public SecretChatLogEventBaseput(this); + init_from(std::move(other)); } } ListNode &operator=(ListNode &&other) { + if (this == &other) { + return *this; + } + this->remove(); if (!other.empty()) { - ListNode *head = other.prev; - other.remove(); - head->put(this); + init_from(std::move(other)); } return *this; @@ -58,11 +58,12 @@ struct ListNode { } void put(ListNode *other) { - other->connect(next); - this->connect(other); + DCHECK(other->empty()); + put_unsafe(other); } void put_back(ListNode *other) { + DCHECK(other->empty()); prev->connect(other); other->connect(this); } @@ -87,6 +88,17 @@ struct ListNode { next = this; prev = this; } + + void init_from(ListNode &&other) { + ListNode *head = other.prev; + other.remove(); + head->put_unsafe(this); + } + + void put_unsafe(ListNode *other) { + other->connect(next); + this->connect(other); + } }; } // namespace td