From 92df8f982779b4b08b433df60d1adb213d03862f Mon Sep 17 00:00:00 2001 From: levlam Date: Wed, 26 Feb 2020 18:15:19 +0300 Subject: [PATCH] Remove unneeded brackets. GitOrigin-RevId: 0b8a2ae21d28e6c276db8b45ffb4d127800f5d73 --- td/telegram/ConfigManager.cpp | 2 +- td/telegram/ContactsManager.cpp | 4 ++-- td/telegram/DialogDb.cpp | 6 +++--- td/telegram/MessageContent.cpp | 2 +- td/telegram/MessagesDb.cpp | 6 +++--- td/telegram/NotificationManager.cpp | 2 +- td/telegram/SecureStorage.cpp | 4 ++-- td/telegram/StickersManager.cpp | 2 +- td/telegram/net/SessionProxy.cpp | 2 +- tdactor/td/actor/impl/ConcurrentScheduler.cpp | 2 +- tdactor/td/actor/impl/Scheduler.cpp | 2 +- tdactor/td/actor/impl/Scheduler.h | 6 +++--- tddb/td/db/SqliteKeyValue.cpp | 2 +- tdnet/td/net/SslStream.cpp | 4 ++-- tdutils/td/utils/Random.cpp | 2 +- tdutils/td/utils/ScopeGuard.h | 2 +- tdutils/td/utils/Status.h | 6 +++--- tdutils/test/misc.cpp | 9 ++++----- test/db.cpp | 2 +- 19 files changed, 33 insertions(+), 34 deletions(-) diff --git a/td/telegram/ConfigManager.cpp b/td/telegram/ConfigManager.cpp index cc9a069d..5e3ecfd0 100644 --- a/td/telegram/ConfigManager.cpp +++ b/td/telegram/ConfigManager.cpp @@ -791,7 +791,7 @@ class ConfigRecoverer : public Actor { PromiseCreator::lambda([actor_id = actor_shared(this)](Result r_simple_config) { send_closure(actor_id, &ConfigRecoverer::on_simple_config, std::move(r_simple_config), false); }); - auto get_simple_config = [&]() { + auto get_simple_config = [&] { switch (simple_config_turn_ % 4) { case 2: return get_simple_config_azure; diff --git a/td/telegram/ContactsManager.cpp b/td/telegram/ContactsManager.cpp index f434e636..c893bba5 100644 --- a/td/telegram/ContactsManager.cpp +++ b/td/telegram/ContactsManager.cpp @@ -12426,7 +12426,7 @@ void ContactsManager::on_chat_update(telegram_api::chat &chat, const char *sourc return; } - DialogParticipantStatus status = [&]() { + DialogParticipantStatus status = [&] { bool is_creator = 0 != (chat.flags_ & CHAT_FLAG_USER_IS_CREATOR); bool has_left = 0 != (chat.flags_ & CHAT_FLAG_USER_HAS_LEFT); bool was_kicked = 0 != (chat.flags_ & CHAT_FLAG_USER_WAS_KICKED); @@ -12590,7 +12590,7 @@ void ContactsManager::on_chat_update(telegram_api::channel &channel, const char is_slow_mode_enabled = false; } - DialogParticipantStatus status = [&]() { + DialogParticipantStatus status = [&] { bool has_left = (channel.flags_ & CHANNEL_FLAG_USER_HAS_LEFT) != 0; bool is_creator = (channel.flags_ & CHANNEL_FLAG_USER_IS_CREATOR) != 0; diff --git a/td/telegram/DialogDb.cpp b/td/telegram/DialogDb.cpp index b5c7d4ac..80a7a559 100644 --- a/td/telegram/DialogDb.cpp +++ b/td/telegram/DialogDb.cpp @@ -38,19 +38,19 @@ Status init_dialog_db(SqliteDb &db, int32 version, bool &was_created) { version = 0; } - auto create_notification_group_table = [&db]() { + auto create_notification_group_table = [&db] { return db.exec( "CREATE TABLE IF NOT EXISTS notification_groups (notification_group_id INT4 PRIMARY KEY, dialog_id " "INT8, last_notification_date INT4)"); }; - auto create_last_notification_date_index = [&db]() { + auto create_last_notification_date_index = [&db] { return db.exec( "CREATE INDEX IF NOT EXISTS notification_group_by_last_notification_date ON notification_groups " "(last_notification_date, dialog_id, notification_group_id) WHERE last_notification_date IS NOT NULL"); }; - auto add_dialogs_in_folder_index = [&db]() { + auto add_dialogs_in_folder_index = [&db] { return db.exec( "CREATE INDEX IF NOT EXISTS dialog_in_folder_by_dialog_order ON dialogs (folder_id, dialog_order, dialog_id) " "WHERE folder_id IS NOT NULL"); diff --git a/td/telegram/MessageContent.cpp b/td/telegram/MessageContent.cpp index a69434da..4c1e20c7 100644 --- a/td/telegram/MessageContent.cpp +++ b/td/telegram/MessageContent.cpp @@ -4476,7 +4476,7 @@ void update_message_content_file_id_remote(MessageContent *content, FileId file_ if (file_id.get_remote() == 0) { return; } - FileId *old_file_id = [&]() { + FileId *old_file_id = [&] { switch (content->get_type()) { case MessageContentType::Animation: return &static_cast(content)->file_id; diff --git a/td/telegram/MessagesDb.cpp b/td/telegram/MessagesDb.cpp index c549191c..3e744d68 100644 --- a/td/telegram/MessagesDb.cpp +++ b/td/telegram/MessagesDb.cpp @@ -85,7 +85,7 @@ Status init_messages_db(SqliteDb &db, int32 version) { return Status::OK(); }; - auto add_call_index = [&db]() { + auto add_call_index = [&db] { for (int i = static_cast(SearchMessagesFilter::Call) - 1; i < static_cast(SearchMessagesFilter::MissedCall); i++) { TRY_STATUS(db.exec(PSLICE() << "CREATE INDEX IF NOT EXISTS full_message_index_" << i @@ -93,12 +93,12 @@ Status init_messages_db(SqliteDb &db, int32 version) { } return Status::OK(); }; - auto add_notification_id_index = [&db]() { + auto add_notification_id_index = [&db] { return db.exec( "CREATE INDEX IF NOT EXISTS message_by_notification_id ON messages (dialog_id, notification_id) WHERE " "notification_id IS NOT NULL"); }; - auto add_scheduled_messages_table = [&db]() { + auto add_scheduled_messages_table = [&db] { TRY_STATUS( db.exec("CREATE TABLE IF NOT EXISTS scheduled_messages (dialog_id INT8, message_id INT8, " "server_message_id INT4, data BLOB, PRIMARY KEY (dialog_id, message_id))")); diff --git a/td/telegram/NotificationManager.cpp b/td/telegram/NotificationManager.cpp index 9c0debd6..7e0ef809 100644 --- a/td/telegram/NotificationManager.cpp +++ b/td/telegram/NotificationManager.cpp @@ -818,7 +818,7 @@ int32 NotificationManager::get_notification_delay_ms(DialogId dialog_id, const P return MIN_NOTIFICATION_DELAY_MS; } - auto delay_ms = [&]() { + auto delay_ms = [&] { auto online_info = td_->contacts_manager_->get_my_online_status(); if (!online_info.is_online_local && online_info.is_online_remote) { // If we are offline, but online from some other client, then delay notification diff --git a/td/telegram/SecureStorage.cpp b/td/telegram/SecureStorage.cpp index c2c43aaa..ce3a6ff0 100644 --- a/td/telegram/SecureStorage.cpp +++ b/td/telegram/SecureStorage.cpp @@ -225,7 +225,7 @@ Secret Secret::clone() const { } EncryptedSecret Secret::encrypt(Slice key, Slice salt, EnryptionAlgorithm algorithm) { - auto aes_cbc_state = [&]() { + auto aes_cbc_state = [&] { switch (algorithm) { case EnryptionAlgorithm::Sha512: return calc_aes_cbc_state_sha512(PSLICE() << salt << key << salt); @@ -255,7 +255,7 @@ Result EncryptedSecret::create(Slice encrypted_secret) { } Result EncryptedSecret::decrypt(Slice key, Slice salt, EnryptionAlgorithm algorithm) { - auto aes_cbc_state = [&]() { + auto aes_cbc_state = [&] { switch (algorithm) { case EnryptionAlgorithm::Sha512: return calc_aes_cbc_state_sha512(PSLICE() << salt << key << salt); diff --git a/td/telegram/StickersManager.cpp b/td/telegram/StickersManager.cpp index 78095f88..2fd3e6c0 100644 --- a/td/telegram/StickersManager.cpp +++ b/td/telegram/StickersManager.cpp @@ -3596,7 +3596,7 @@ tl_object_ptr StickersManager::get_input_stic tl_object_ptr mask_coords; if (sticker->mask_position_ != nullptr && sticker->mask_position_->point_ != nullptr) { - auto point = [mask_point = std::move(sticker->mask_position_->point_)]() { + auto point = [mask_point = std::move(sticker->mask_position_->point_)] { switch (mask_point->get_id()) { case td_api::maskPointForehead::ID: return 0; diff --git a/td/telegram/net/SessionProxy.cpp b/td/telegram/net/SessionProxy.cpp index 17a11052..2b57dd96 100644 --- a/td/telegram/net/SessionProxy.cpp +++ b/td/telegram/net/SessionProxy.cpp @@ -171,7 +171,7 @@ void SessionProxy::open_session(bool force) { // 1. All unauthorized query will be sent into the same SessionProxy // 2. All authorized query are delayed before we have authorization // So only one SessionProxy will be active before we have authorization key - auto should_open = [&]() { + auto should_open = [&] { if (force) { return true; } diff --git a/tdactor/td/actor/impl/ConcurrentScheduler.cpp b/tdactor/td/actor/impl/ConcurrentScheduler.cpp index cab7841b..f2676b42 100644 --- a/tdactor/td/actor/impl/ConcurrentScheduler.cpp +++ b/tdactor/td/actor/impl/ConcurrentScheduler.cpp @@ -78,7 +78,7 @@ void ConcurrentScheduler::start() { #if !TD_THREAD_UNSUPPORTED && !TD_EVENTFD_UNSUPPORTED for (size_t i = 1; i + extra_scheduler_ < schedulers_.size(); i++) { auto &sched = schedulers_[i]; - threads_.push_back(td::thread([&]() { + threads_.push_back(td::thread([&] { #if TD_PORT_WINDOWS detail::Iocp::Guard iocp_guard(iocp_.get()); #endif diff --git a/tdactor/td/actor/impl/Scheduler.cpp b/tdactor/td/actor/impl/Scheduler.cpp index 1c653507..9eaaedac 100644 --- a/tdactor/td/actor/impl/Scheduler.cpp +++ b/tdactor/td/actor/impl/Scheduler.cpp @@ -244,7 +244,7 @@ void Scheduler::clear() { if (callback_) { // can't move lambda with unique_ptr inside into std::function auto ptr = actor_info_pool_.release(); - callback_->register_at_finish([=]() { delete ptr; }); + callback_->register_at_finish([ptr] { delete ptr; }); } else { actor_info_pool_.reset(); } diff --git a/tdactor/td/actor/impl/Scheduler.h b/tdactor/td/actor/impl/Scheduler.h index c72b158a..36b7b552 100644 --- a/tdactor/td/actor/impl/Scheduler.h +++ b/tdactor/td/actor/impl/Scheduler.h @@ -235,7 +235,7 @@ void Scheduler::send_lambda(ActorRef actor_ref, EventT &&lambda) { event_context_ptr_->link_token = actor_ref.token(); lambda(); }, - [&]() { + [&] { auto event = Event::lambda(std::forward(lambda)); event.set_link_token(actor_ref.token()); return event; @@ -250,7 +250,7 @@ void Scheduler::send_closure(ActorRef actor_ref, EventT &&closure) { event_context_ptr_->link_token = actor_ref.token(); closure.run(static_cast(actor_info->get_actor_unsafe())); }, - [&]() { + [&] { auto event = Event::immediate_closure(std::forward(closure)); event.set_link_token(actor_ref.token()); return event; @@ -262,7 +262,7 @@ void Scheduler::send(ActorRef actor_ref, Event &&event) { event.set_link_token(actor_ref.token()); return send_impl( actor_ref.get(), [&](ActorInfo *actor_info) { do_event(actor_info, std::move(event)); }, - [&]() { return std::move(event); }); + [&] { return std::move(event); }); } inline void Scheduler::subscribe(PollableFd fd, PollFlags flags) { diff --git a/tddb/td/db/SqliteKeyValue.cpp b/tddb/td/db/SqliteKeyValue.cpp index b0cf00a1..c9687d90 100644 --- a/tddb/td/db/SqliteKeyValue.cpp +++ b/tddb/td/db/SqliteKeyValue.cpp @@ -24,7 +24,7 @@ Result SqliteKeyValue::init(string path) { } Status SqliteKeyValue::init_with_connection(SqliteDb connection, string table_name) { - auto init_guard = ScopeExit() + [&]() { + auto init_guard = ScopeExit() + [&] { close(); }; db_ = std::move(connection); diff --git a/tdnet/td/net/SslStream.cpp b/tdnet/td/net/SslStream.cpp index 36636104..ab1a2e4b 100644 --- a/tdnet/td/net/SslStream.cpp +++ b/tdnet/td/net/SslStream.cpp @@ -224,7 +224,7 @@ class SslStreamImpl { if (ssl_ctx == nullptr) { return create_openssl_error(-7, "Failed to create an SSL context"); } - auto ssl_ctx_guard = ScopeExit() + [&]() { + auto ssl_ctx_guard = ScopeExit() + [&] { SSL_CTX_free(ssl_ctx); }; long options = 0; @@ -313,7 +313,7 @@ class SslStreamImpl { if (ssl_handle == nullptr) { return create_openssl_error(-13, "Failed to create an SSL handle"); } - auto ssl_handle_guard = ScopeExit() + [&]() { + auto ssl_handle_guard = ScopeExit() + [&] { do_ssl_shutdown(ssl_handle); SSL_free(ssl_handle); }; diff --git a/tdutils/td/utils/Random.cpp b/tdutils/td/utils/Random.cpp index 234a081e..1ef70ba9 100644 --- a/tdutils/td/utils/Random.cpp +++ b/tdutils/td/utils/Random.cpp @@ -135,7 +135,7 @@ int Random::fast(int min, int max) { } Random::Xorshift128plus::Xorshift128plus(uint64 seed) { - auto next = [&]() { + auto next = [&] { // splitmix64 seed += static_cast(0x9E3779B97F4A7C15); uint64 z = seed; diff --git a/tdutils/td/utils/ScopeGuard.h b/tdutils/td/utils/ScopeGuard.h index c4c8f9fb..a100f2f7 100644 --- a/tdutils/td/utils/ScopeGuard.h +++ b/tdutils/td/utils/ScopeGuard.h @@ -74,4 +74,4 @@ auto operator+(ScopeExit, FunctionT &&func) { } // namespace td -#define SCOPE_EXIT auto TD_CONCAT(SCOPE_EXIT_VAR_, __LINE__) = ::td::ScopeExit() + [&]() +#define SCOPE_EXIT auto TD_CONCAT(SCOPE_EXIT_VAR_, __LINE__) = ::td::ScopeExit() + [&] diff --git a/tdutils/td/utils/Status.h b/tdutils/td/utils/Status.h index 3a40d07c..393db001 100644 --- a/tdutils/td/utils/Status.h +++ b/tdutils/td/utils/Status.h @@ -75,19 +75,19 @@ #if TD_PORT_POSIX #define OS_ERROR(message) \ - [&]() { \ + [&] { \ auto saved_errno = errno; \ return ::td::Status::PosixError(saved_errno, (message)); \ }() #define OS_SOCKET_ERROR(message) OS_ERROR(message) #elif TD_PORT_WINDOWS #define OS_ERROR(message) \ - [&]() { \ + [&] { \ auto saved_error = ::GetLastError(); \ return ::td::Status::WindowsError(saved_error, (message)); \ }() #define OS_SOCKET_ERROR(message) \ - [&]() { \ + [&] { \ auto saved_error = ::WSAGetLastError(); \ return ::td::Status::WindowsError(saved_error, (message)); \ }() diff --git a/tdutils/test/misc.cpp b/tdutils/test/misc.cpp index 9c44678a..ec61a518 100644 --- a/tdutils/test/misc.cpp +++ b/tdutils/test/misc.cpp @@ -831,11 +831,10 @@ TEST(Misc, Bits) { uint8 buf[8] = {1, 90, 2, 18, 129, 255, 0, 2}; uint64 num2 = bswap64(as(buf)); - uint64 num = - (static_cast(buf[0]) << 56) | (static_cast(buf[1]) << 48) | - (static_cast(buf[2]) << 40) | (static_cast(buf[3]) << 32) | - (static_cast(buf[4]) << 24) | (static_cast(buf[5]) << 16) | - (static_cast(buf[6]) << 8) | (static_cast(buf[7])); + uint64 num = (static_cast(buf[0]) << 56) | (static_cast(buf[1]) << 48) | + (static_cast(buf[2]) << 40) | (static_cast(buf[3]) << 32) | + (static_cast(buf[4]) << 24) | (static_cast(buf[5]) << 16) | + (static_cast(buf[6]) << 8) | (static_cast(buf[7])); ASSERT_EQ(num, num2); ASSERT_EQ(0, count_bits32(0)); diff --git a/test/db.cpp b/test/db.cpp index f9f33726..19cc9441 100644 --- a/test/db.cpp +++ b/test/db.cpp @@ -377,7 +377,7 @@ TEST(DB, thread_key_value) { std::vector threads(threads_n); std::vector> res(threads_n); for (int i = 0; i < threads_n; i++) { - threads[i] = thread([&ts_kv, &queries, &res, i]() { + threads[i] = thread([&ts_kv, &queries, &res, i] { for (auto q : queries[i]) { ts_kv.do_query(q); res[i].push_back(q);