1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 05:07:35 +00:00

Applications: Change static constexpr variables to constexpr

Function-local `static constexpr` variables can be `constexpr`. This
can reduce memory consumption, binary size, and offer additional
compiler optimizations.
This commit is contained in:
Lenny Maiorani 2022-02-09 17:45:15 -07:00 committed by Andreas Kling
parent 7012a5eb0b
commit 1dd70a6f49
10 changed files with 67 additions and 60 deletions

View file

@ -8,6 +8,7 @@
#include <AK/Array.h>
#include <AK/Hex.h>
#include <AK/String.h>
#include <AK/StringView.h>
#include <Applications/HexEditor/FindDialogGML.h>
#include <LibGUI/BoxLayout.h>
#include <LibGUI/Button.h>
@ -17,19 +18,12 @@
#include <LibGUI/Widget.h>
struct Option {
String title;
StringView title;
OptionId opt;
bool enabled;
bool default_action;
};
static const Array<Option, 2> options = {
{
{ "ASCII String", OPTION_ASCII_STRING, true, true },
{ "Hex value", OPTION_HEX_VALUE, true, false },
}
};
int FindDialog::show(GUI::Window* parent_window, String& out_text, ByteBuffer& out_buffer, bool& find_all)
{
auto dialog = FindDialog::construct();
@ -107,6 +101,13 @@ FindDialog::FindDialog()
m_find_all_button = *main_widget.find_descendant_of_type_named<GUI::Button>("find_all_button");
m_cancel_button = *main_widget.find_descendant_of_type_named<GUI::Button>("cancel_button");
constexpr Array<Option, 2> options = {
{
{ "ASCII String", OPTION_ASCII_STRING, true, true },
{ "Hex value", OPTION_HEX_VALUE, true, false },
}
};
auto& radio_container = *main_widget.find_descendant_of_type_named<GUI::Widget>("radio_container");
for (size_t i = 0; i < options.size(); i++) {
auto action = options[i];
@ -114,7 +115,7 @@ FindDialog::FindDialog()
radio.set_enabled(action.enabled);
radio.set_text(action.title);
radio.on_checked = [this, i](auto) {
radio.on_checked = [this, i, &options](auto) {
m_selected_option = options[i].opt;
};