Repository: godotengine/godot
File: editor/plugins/text_control_editor_plugin.cpp (C++)

Code before:
			edited_font_size = "normal_font_size";
		} else {
			edited_color = "font_color";
			edited_font = "font";
			edited_font_size = "font_size";
		}

		// Get font override.
		Ref<Font> font;
		if (edited_control->has_theme_font_override(edited_font)) {
			font = edited_control->get_theme_font(edited_font);
		}
		if (font.is_valid()) {
			if (font->get_data_count() != 1) {
				// Composite font, save it to "custom_font" to allow undoing font change.
				custom_font = font;
				_update_fonts_menu();
				font_list->select(FONT_INFO_USER_CUSTOM);
				_update_styles_menu();
				font_style_list->select(0);
			} else {
				// Single face font, search for the font with matching name and style.
				String name = font->get_data(0)->get_font_name();
				String style = font->get_data(0)->get_font_style_name();
				if (fonts.has(name) && fonts[name].has(style)) {
					_update_fonts_menu();
					for (int i = 0; i < font_list->get_item_count(); i++) {
						if (font_list->get_item_text(i) == name) {
							font_list->select(i);
							break;
						}
					}
					_update_styles_menu();
					for (int i = 0; i < font_style_list->get_item_count(); i++) {
						if (font_style_list->get_item_text(i) == style) {
							font_style_list->select(i);
							break;
						}
					}
				} else {
					// Unknown font, save it to "custom_font" to allow undoing font change.
					custom_font = font;
					_update_fonts_menu();
					font_list->select(FONT_INFO_USER_CUSTOM);
					_update_styles_menu();
					font_style_list->select(0);
				}
			}
		} else {
			// No font override, select "Theme Default".
			_update_fonts_menu();

Review comment (performance):
To be confirmed, but I think these could be changed to be wrapped with `SNAME()` (and defined as `StringName` instead of `String`) to reuse preallocated StringNames for performance.

Code after:
		bool same_style = true;
		int font_size = 0;
		bool same_font_size = true;
		int outline_size = 0;
		bool same_outline_size = true;
		Color font_color = Color{ 1.0f, 1.0f, 1.0f };
		bool same_font_color = true;
		Color outline_color = Color{ 1.0f, 1.0f, 1.0f };
		bool same_outline_color = true;

		_update_fonts_menu();
		_update_styles_menu();

		int count = edited_controls.size();
		for (int i = 0; i < count; ++i) {
			Control *edited_control = edited_controls[i];

			String edited_color;
			String edited_font;
			String edited_font_size;

			// Get override names.
			if (edited_control->is_class("RichTextLabel")) {
				edited_color = "default_color";
				edited_font = "normal_font";
				edited_font_size = "normal_font_size";
			} else {
				edited_color = "font_color";
				edited_font = "font";
				edited_font_size = "font_size";
			}

			// Get font override.
			Ref<Font> font;
			if (edited_control->has_theme_font_override(edited_font)) {
				font = edited_control->get_theme_font(edited_font);
			}

			if (font.is_valid()) {
				if (font->get_data_count() != 1) {
					custom_font = font;
					if (i > 0) {
						same_font = same_font && (font_selected == FONT_INFO_USER_CUSTOM);
						same_style = same_style && (style_selected == 0);
					}

					font_selected = FONT_INFO_USER_CUSTOM;
					style_selected = 0;
				} else {
					String name = font->get_data(0)->get_font_name();
					String style = font->get_data(0)->get_font_style_name();