From 0c8e63c2f545a845c7f4e33885843f390706cf15 Mon Sep 17 00:00:00 2001 From: levlam Date: Tue, 23 Jan 2024 20:29:31 +0300 Subject: [PATCH] Optimize set_default_integer_option. --- td/telegram/OptionManager.cpp | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/td/telegram/OptionManager.cpp b/td/telegram/OptionManager.cpp index edc920085..50b18af8a 100644 --- a/td/telegram/OptionManager.cpp +++ b/td/telegram/OptionManager.cpp @@ -79,12 +79,20 @@ OptionManager::OptionManager(Td *td) send_closure(G()->td(), &Td::send_update, td_api::make_object("utc_time_offset", get_option_value_object(utc_time_offset))); - auto set_default_integer_option = [&](Slice name, int32 value) { - if (!have_option(name)) { - set_option_integer(name, value); + auto set_default_integer_option = [&](string name, int32 value) { + if (options_->isset(name)) { + return; + } + auto str_value = PSTRING() << 'I' << value; + options_->set(name, str_value); + option_pmc_->set(name, str_value); + + if (!is_internal_option(name)) { + send_closure( + G()->td(), &Td::send_update, + td_api::make_object(name, td_api::make_object(value))); } }; - set_default_integer_option("message_caption_length_max", 1024); set_default_integer_option("message_reply_quote_length_max", 1024); set_default_integer_option("story_caption_length_max", 200);