From 1bdc41faa108336e1bc37a0e56e5b619ac25d38c Mon Sep 17 00:00:00 2001 From: Pavel Shliak Date: Mon, 11 Nov 2024 14:22:44 +0400 Subject: [PATCH] LibWeb: Reduce SelectItemOption struct from 40 to 32 bytes --- Libraries/LibWeb/HTML/HTMLSelectElement.cpp | 4 ++-- Libraries/LibWeb/HTML/SelectItem.cpp | 2 +- Libraries/LibWeb/HTML/SelectItem.h | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Libraries/LibWeb/HTML/HTMLSelectElement.cpp b/Libraries/LibWeb/HTML/HTMLSelectElement.cpp index 358692829c0..185fb1b9ee3 100644 --- a/Libraries/LibWeb/HTML/HTMLSelectElement.cpp +++ b/Libraries/LibWeb/HTML/HTMLSelectElement.cpp @@ -389,7 +389,7 @@ void HTMLSelectElement::show_the_picker_if_applicable() for (auto const& child : opt_group_element.children_as_vector()) { if (is(*child)) { auto& option_element = verify_cast(*child); - option_group_items.append(SelectItemOption { id_counter++, strip_newlines(option_element.text_content()), option_element.value(), option_element.selected(), option_element.disabled(), option_element }); + option_group_items.append(SelectItemOption { id_counter++, option_element.selected(), option_element.disabled(), option_element, strip_newlines(option_element.text_content()), option_element.value() }); } } m_select_items.append(SelectItemOptionGroup { opt_group_element.get_attribute(AttributeNames::label).value_or(String {}), option_group_items }); @@ -397,7 +397,7 @@ void HTMLSelectElement::show_the_picker_if_applicable() if (is(*child)) { auto& option_element = verify_cast(*child); - m_select_items.append(SelectItemOption { id_counter++, strip_newlines(option_element.text_content()), option_element.value(), option_element.selected(), option_element.disabled(), option_element }); + m_select_items.append(SelectItemOption { id_counter++, option_element.selected(), option_element.disabled(), option_element, strip_newlines(option_element.text_content()), option_element.value() }); } if (is(*child)) diff --git a/Libraries/LibWeb/HTML/SelectItem.cpp b/Libraries/LibWeb/HTML/SelectItem.cpp index d0f6d5307a6..215ac7e7b5b 100644 --- a/Libraries/LibWeb/HTML/SelectItem.cpp +++ b/Libraries/LibWeb/HTML/SelectItem.cpp @@ -27,7 +27,7 @@ ErrorOr IPC::decode(Decoder& decoder) auto value = TRY(decoder.decode()); auto selected = TRY(decoder.decode()); auto disabled = TRY(decoder.decode()); - return Web::HTML::SelectItemOption { id, move(label), move(value), selected, disabled }; + return Web::HTML::SelectItemOption { id, selected, disabled, {}, move(label), move(value) }; } template<> diff --git a/Libraries/LibWeb/HTML/SelectItem.h b/Libraries/LibWeb/HTML/SelectItem.h index 8278876501c..41c652747b6 100644 --- a/Libraries/LibWeb/HTML/SelectItem.h +++ b/Libraries/LibWeb/HTML/SelectItem.h @@ -14,11 +14,11 @@ namespace Web::HTML { struct SelectItemOption { u32 id { 0 }; - String label {}; - String value {}; bool selected { false }; bool disabled { false }; JS::GCPtr option_element {}; + String label {}; + String value {}; }; struct SelectItemOptionGroup {