Add List::init_from.
GitOrigin-RevId: 17a6f374ff0b568c6e2d056053539fb2947f22d3
This commit is contained in:
parent
64094b0a23
commit
cd451b7c45
@ -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)
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user