Explicitly capture copied lambda parameters.

GitOrigin-RevId: 653e4c6b640a77bb757576d974906a30d0732a4a
This commit is contained in:
levlam 2020-09-27 02:20:42 +03:00
parent f1dcdc9a49
commit 75aac4dd46
5 changed files with 17 additions and 15 deletions

View File

@ -56,12 +56,12 @@ class RingBench : public td::Benchmark {
send_closure_later(next_actor, &PassActor::pass, n - 1);
} else {
// TODO: it is three times faster than send_event
// may be send event could be further optimized?
// maybe send event could be further optimized?
::td::Scheduler::instance()->hack(static_cast<td::ActorId<Actor>>(next_actor),
td::Event::raw(static_cast<td::uint32>(n - 1)));
}
} else if (type == 4) {
send_lambda(next_actor, [=, ptr = next_actor.get_actor_unsafe()] { ptr->pass(n - 1); });
send_lambda(next_actor, [n, ptr = next_actor.get_actor_unsafe()] { ptr->pass(n - 1); });
}
}
}

View File

@ -378,10 +378,10 @@ class DialogDbAsync : public DialogDbAsyncInterface {
void add_dialog(DialogId dialog_id, FolderId folder_id, int64 order, BufferSlice data,
vector<NotificationGroupKey> notification_groups, Promise<> promise) {
add_write_query([=, promise = std::move(promise), data = std::move(data),
add_write_query([this, dialog_id, folder_id, order, promise = std::move(promise), data = std::move(data),
notification_groups = std::move(notification_groups)](Unit) mutable {
this->on_write_result(std::move(promise), sync_db_->add_dialog(dialog_id, folder_id, order, std::move(data),
std::move(notification_groups)));
on_write_result(std::move(promise), sync_db_->add_dialog(dialog_id, folder_id, order, std::move(data),
std::move(notification_groups)));
});
}

View File

@ -221,7 +221,8 @@ bool Global::ignore_backgrond_updates() const {
}
void Global::set_net_query_stats(std::shared_ptr<NetQueryStats> net_query_stats) {
net_query_creator_.set_create_func([=] { return td::make_unique<NetQueryCreator>(net_query_stats); });
net_query_creator_.set_create_func(
[net_query_stats = std::move(net_query_stats)] { return td::make_unique<NetQueryCreator>(net_query_stats); });
}
void Global::set_net_query_dispatcher(unique_ptr<NetQueryDispatcher> net_query_dispatcher) {

View File

@ -1017,22 +1017,23 @@ class MessagesDbAsync : public MessagesDbAsyncInterface {
void add_message(FullMessageId full_message_id, ServerMessageId unique_message_id, UserId sender_user_id,
int64 random_id, int32 ttl_expires_at, int32 index_mask, int64 search_id, string text,
NotificationId notification_id, BufferSlice data, Promise<> promise) {
add_write_query([=, promise = std::move(promise), data = std::move(data), text = std::move(text)](Unit) mutable {
this->on_write_result(
std::move(promise),
sync_db_->add_message(full_message_id, unique_message_id, sender_user_id, random_id, ttl_expires_at,
index_mask, search_id, std::move(text), notification_id, std::move(data)));
add_write_query([this, full_message_id, unique_message_id, sender_user_id, random_id, ttl_expires_at, index_mask,
search_id, text = std::move(text), notification_id, data = std::move(data),
promise = std::move(promise)](Unit) mutable {
on_write_result(std::move(promise), sync_db_->add_message(full_message_id, unique_message_id, sender_user_id,
random_id, ttl_expires_at, index_mask, search_id,
std::move(text), notification_id, std::move(data)));
});
}
void add_scheduled_message(FullMessageId full_message_id, BufferSlice data, Promise<> promise) {
add_write_query([this, full_message_id, promise = std::move(promise), data = std::move(data)](Unit) mutable {
this->on_write_result(std::move(promise), sync_db_->add_scheduled_message(full_message_id, std::move(data)));
on_write_result(std::move(promise), sync_db_->add_scheduled_message(full_message_id, std::move(data)));
});
}
void delete_message(FullMessageId full_message_id, Promise<> promise) {
add_write_query([=, promise = std::move(promise)](Unit) mutable {
this->on_write_result(std::move(promise), sync_db_->delete_message(full_message_id));
add_write_query([this, full_message_id, promise = std::move(promise)](Unit) mutable {
on_write_result(std::move(promise), sync_db_->delete_message(full_message_id));
});
}
void on_write_result(Promise<> promise, Status status) {

View File

@ -500,7 +500,7 @@ void PasswordManager::update_password_settings(UpdateSettings update_settings, P
auto password = update_settings.current_password;
get_full_state(
std::move(password),
PromiseCreator::lambda([=, actor_id = actor_id(this), result_promise = std::move(result_promise),
PromiseCreator::lambda([actor_id = actor_id(this), result_promise = std::move(result_promise),
update_settings = std::move(update_settings)](Result<PasswordFullState> r_state) mutable {
if (r_state.is_error()) {
return result_promise.set_error(r_state.move_as_error());