Use FlatHashSet to check internal options.

This commit is contained in:
levlam 2024-01-25 18:50:37 +03:00
parent dfdad00dca
commit 4464a8479b

View File

@ -316,77 +316,101 @@ void OptionManager::on_update_server_time_difference() {
} }
bool OptionManager::is_internal_option(Slice name) { bool OptionManager::is_internal_option(Slice name) {
switch (name[0]) { static const FlatHashSet<Slice, SliceHash> internal_options{"about_length_limit_default",
case 'a': "about_length_limit_premium",
return name == "about_length_limit_default" || name == "about_length_limit_premium" || "aggressive_anti_spam_supergroup_member_count_min",
name == "aggressive_anti_spam_supergroup_member_count_min" || name == "animated_emoji_zoom" || "animated_emoji_zoom",
name == "animation_search_emojis" || name == "animation_search_provider" || "animation_search_emojis",
name == "authorization_autoconfirm_period"; "animation_search_provider",
case 'b': "authorization_autoconfirm_period",
return name == "base_language_pack_version"; "base_language_pack_version",
case 'c': "call_receive_timeout_ms",
return name == "call_receive_timeout_ms" || name == "call_ring_timeout_ms" || "call_ring_timeout_ms",
name == "caption_length_limit_default" || name == "caption_length_limit_premium" || "caption_length_limit_default",
name == "channel_bg_icon_level_min" || name == "channel_custom_wallpaper_level_min" || "caption_length_limit_premium",
name == "channel_emoji_status_level_min" || name == "channel_profile_bg_icon_level_min" || "channel_bg_icon_level_min",
name == "channel_wallpaper_level_min" || name == "channels_limit_default" || "channel_custom_wallpaper_level_min",
name == "channels_limit_premium" || name == "channels_public_limit_default" || "channel_emoji_status_level_min",
name == "channels_public_limit_premium" || name == "channels_read_media_period" || "channel_profile_bg_icon_level_min",
name == "chat_read_mark_expire_period" || name == "chat_read_mark_size_threshold" || "channel_wallpaper_level_min",
name == "chatlist_invites_limit_default" || name == "chatlist_invites_limit_premium" || "channels_limit_default",
name == "chatlists_joined_limit_default" || name == "chatlists_joined_limit_premium"; "channels_limit_premium",
case 'd': "channels_public_limit_default",
return name == "dc_txt_domain_name" || name == "default_reaction" || name == "default_reaction_needs_sync" || "channels_public_limit_premium",
name == "dialog_filters_chats_limit_default" || name == "dialog_filters_chats_limit_premium" || "channels_read_media_period",
name == "dialog_filters_limit_default" || name == "dialog_filters_limit_premium" || "chat_read_mark_expire_period",
name == "dialogs_folder_pinned_limit_default" || name == "dialogs_folder_pinned_limit_premium" || "chat_read_mark_size_threshold",
name == "dialogs_pinned_limit_default" || name == "dialogs_pinned_limit_premium" || "chatlist_invites_limit_default",
name == "dice_emojis" || name == "dice_success_values"; "chatlist_invites_limit_premium",
case 'e': "chatlists_joined_limit_default",
return name == "edit_time_limit" || name == "emoji_sounds"; "chatlists_joined_limit_premium",
case 'f': "dc_txt_domain_name",
return name == "fragment_prefixes"; "default_reaction",
case 'h': "default_reaction_needs_sync",
return name == "hidden_members_group_size_min"; "dialog_filters_chats_limit_default",
case 'i': "dialog_filters_chats_limit_premium",
return name == "ignored_restriction_reasons"; "dialog_filters_limit_default",
case 'l': "dialog_filters_limit_premium",
return name == "language_pack_version"; "dialogs_folder_pinned_limit_default",
case 'm': "dialogs_folder_pinned_limit_premium",
return name == "my_phone_number"; "dialogs_pinned_limit_default",
case 'n': "dialogs_pinned_limit_premium",
return name == "need_premium_for_story_caption_entities" || name == "need_synchronize_archive_all_stories" || "dice_emojis",
name == "notification_cloud_delay_ms" || name == "notification_default_delay_ms"; "dice_success_values",
case 'o': "edit_time_limit",
return name == "online_cloud_timeout_ms" || name == "online_update_period_ms" || name == "otherwise_relogin_days"; "emoji_sounds",
case 'p': "fragment_prefixes",
return name == "pm_read_date_expire_period" || name == "premium_bot_username" || name == "premium_features" || "hidden_members_group_size_min",
name == "premium_invoice_slug"; "ignored_restriction_reasons",
case 'r': "language_pack_version",
return name == "rating_e_decay" || name == "reactions_uniq_max" || name == "reactions_user_max_default" || "my_phone_number",
name == "reactions_user_max_premium" || name == "recent_stickers_limit" || "need_premium_for_story_caption_entities",
name == "recommended_channels_limit_default" || name == "recommended_channels_limit_premium" || "need_synchronize_archive_all_stories",
name == "restriction_add_platforms" || name == "revoke_pm_inbox" || name == "revoke_time_limit" || "notification_cloud_delay_ms",
name == "revoke_pm_time_limit"; "notification_default_delay_ms",
case 's': "online_cloud_timeout_ms",
return name == "saved_animations_limit" || name == "saved_dialogs_pinned_limit_default" || "online_update_period_ms",
name == "saved_dialogs_pinned_limit_premium" || name == "saved_gifs_limit_default" || "otherwise_relogin_days",
name == "saved_gifs_limit_premium" || name == "session_count" || name == "since_last_open" || "pm_read_date_expire_period",
name == "stickers_faved_limit_default" || name == "stickers_faved_limit_premium" || "premium_bot_username",
name == "stickers_normal_by_emoji_per_premium_num" || name == "stickers_premium_by_emoji_num" || "premium_features",
name == "stories_changelog_user_id" || name == "stories_sent_monthly_limit_default" || "premium_invoice_slug",
name == "stories_sent_monthly_limit_premium" || name == "stories_sent_weekly_limit_default" || "rating_e_decay",
name == "stories_sent_weekly_limit_premium" || name == "stories_suggested_reactions_limit_default" || "reactions_uniq_max",
name == "stories_suggested_reactions_limit_premium" || name == "story_caption_length_limit_default" || "reactions_user_max_default",
name == "story_caption_length_limit_premium" || name == "story_expiring_limit_default" || "reactions_user_max_premium",
name == "story_expiring_limit_premium"; "recent_stickers_limit",
case 'v': "recommended_channels_limit_default",
return name == "video_note_size_max"; "recommended_channels_limit_premium",
case 'w': "restriction_add_platforms",
return name == "webfile_dc_id"; "revoke_pm_inbox",
default: "revoke_time_limit",
return false; "revoke_pm_time_limit",
} "saved_animations_limit",
"saved_dialogs_pinned_limit_default",
"saved_dialogs_pinned_limit_premium",
"saved_gifs_limit_default",
"saved_gifs_limit_premium",
"session_count",
"since_last_open",
"stickers_faved_limit_default",
"stickers_faved_limit_premium",
"stickers_normal_by_emoji_per_premium_num",
"stickers_premium_by_emoji_num",
"stories_changelog_user_id",
"stories_sent_monthly_limit_default",
"stories_sent_monthly_limit_premium",
"stories_sent_weekly_limit_default",
"stories_sent_weekly_limit_premium",
"stories_suggested_reactions_limit_default",
"stories_suggested_reactions_limit_premium",
"story_caption_length_limit_default",
"story_caption_length_limit_premium",
"story_expiring_limit_default",
"story_expiring_limit_premium",
"video_note_size_max",
"webfile_dc_id"};
return internal_options.count(name) > 0;
} }
td_api::object_ptr<td_api::Update> OptionManager::get_internal_option_update(Slice name) const { td_api::object_ptr<td_api::Update> OptionManager::get_internal_option_update(Slice name) const {