Add List::init_from.

GitOrigin-RevId: 17a6f374ff0b568c6e2d056053539fb2947f22d3
This commit is contained in:
levlam 2020-06-09 17:18:59 +03:00
parent 64094b0a23
commit cd451b7c45
2 changed files with 21 additions and 9 deletions

View File

@ -322,7 +322,7 @@ class OutboundSecretMessage : public SecretChatLogEventBase<OutboundSecretMessag
bool is_sent = false;
// need send push notification to the receiver
// should send such messages with messages_sendEncryptedsService
// should send such messages with messages_sendEncryptedService
bool need_notify_user = false;
bool is_rewritable = false;
// should notify our parent about state of this message (using context and random_id)

View File

@ -28,19 +28,19 @@ struct ListNode {
if (other.empty()) {
clear();
} else {
ListNode *head = other.prev;
other.remove();
head->put(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