From 9ef9751f5f43568c0fc9e81b90e4b751cd350018 Mon Sep 17 00:00:00 2001 From: levlam Date: Tue, 28 Jun 2022 16:43:51 +0300 Subject: [PATCH] Immediately exit UpdatesManager::process_updates if there are no updates to process. --- td/telegram/UpdatesManager.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/td/telegram/UpdatesManager.cpp b/td/telegram/UpdatesManager.cpp index 4e6b88b51..8958739c1 100644 --- a/td/telegram/UpdatesManager.cpp +++ b/td/telegram/UpdatesManager.cpp @@ -2027,14 +2027,15 @@ void UpdatesManager::add_pending_qts_update(tl_object_ptr void UpdatesManager::process_updates(vector> &&updates, bool force_apply, Promise &&promise) { - tl_object_ptr update_pts_changed; - int32 update_count = 0; for (auto &update : updates) { if (update != nullptr) { update_count++; } } + if (update_count == 0) { + return promise.set_value(Unit()); + } MultiPromiseActorSafe mpas{"OnProcessUpdatesMultiPromiseActor"}; Promise lock; @@ -2070,6 +2071,8 @@ void UpdatesManager::process_updates(vector> } } */ + + tl_object_ptr update_pts_changed; for (auto &update : updates) { if (update != nullptr) { // process updateNewChannelMessage first