mirror of
https://github.com/RGBCube/serenity
synced 2025-07-28 16:17:47 +00:00
Everywhere: Add sv suffix to strings relying on StringView(char const*)
Each of these strings would previously rely on StringView's char const* constructor overload, which would call __builtin_strlen on the string. Since we now have operator ""sv, we can replace these with much simpler versions. This opens the door to being able to remove StringView(char const*). No functional changes.
This commit is contained in:
parent
e5f09ea170
commit
3f3f45580a
762 changed files with 8315 additions and 8316 deletions
|
@ -118,13 +118,13 @@ Field::Field(GUI::Label& flag_label, GUI::Label& time_label, GUI::Button& face_b
|
|||
m_time_label.set_text(String::formatted("{}.{}", m_time_elapsed / 10, m_time_elapsed % 10));
|
||||
};
|
||||
m_timer->set_interval(100);
|
||||
m_mine_bitmap = Gfx::Bitmap::try_load_from_file("/res/icons/minesweeper/mine.png").release_value_but_fixme_should_propagate_errors();
|
||||
m_flag_bitmap = Gfx::Bitmap::try_load_from_file("/res/icons/minesweeper/flag.png").release_value_but_fixme_should_propagate_errors();
|
||||
m_badflag_bitmap = Gfx::Bitmap::try_load_from_file("/res/icons/minesweeper/badflag.png").release_value_but_fixme_should_propagate_errors();
|
||||
m_consider_bitmap = Gfx::Bitmap::try_load_from_file("/res/icons/minesweeper/consider.png").release_value_but_fixme_should_propagate_errors();
|
||||
m_default_face_bitmap = Gfx::Bitmap::try_load_from_file("/res/icons/minesweeper/face-default.png").release_value_but_fixme_should_propagate_errors();
|
||||
m_good_face_bitmap = Gfx::Bitmap::try_load_from_file("/res/icons/minesweeper/face-good.png").release_value_but_fixme_should_propagate_errors();
|
||||
m_bad_face_bitmap = Gfx::Bitmap::try_load_from_file("/res/icons/minesweeper/face-bad.png").release_value_but_fixme_should_propagate_errors();
|
||||
m_mine_bitmap = Gfx::Bitmap::try_load_from_file("/res/icons/minesweeper/mine.png"sv).release_value_but_fixme_should_propagate_errors();
|
||||
m_flag_bitmap = Gfx::Bitmap::try_load_from_file("/res/icons/minesweeper/flag.png"sv).release_value_but_fixme_should_propagate_errors();
|
||||
m_badflag_bitmap = Gfx::Bitmap::try_load_from_file("/res/icons/minesweeper/badflag.png"sv).release_value_but_fixme_should_propagate_errors();
|
||||
m_consider_bitmap = Gfx::Bitmap::try_load_from_file("/res/icons/minesweeper/consider.png"sv).release_value_but_fixme_should_propagate_errors();
|
||||
m_default_face_bitmap = Gfx::Bitmap::try_load_from_file("/res/icons/minesweeper/face-default.png"sv).release_value_but_fixme_should_propagate_errors();
|
||||
m_good_face_bitmap = Gfx::Bitmap::try_load_from_file("/res/icons/minesweeper/face-good.png"sv).release_value_but_fixme_should_propagate_errors();
|
||||
m_bad_face_bitmap = Gfx::Bitmap::try_load_from_file("/res/icons/minesweeper/face-bad.png"sv).release_value_but_fixme_should_propagate_errors();
|
||||
for (int i = 0; i < 8; ++i)
|
||||
m_number_bitmap[i] = Gfx::Bitmap::try_load_from_file(String::formatted("/res/icons/minesweeper/{}.png", i + 1)).release_value_but_fixme_should_propagate_errors();
|
||||
// Square with mine will be filled with background color later, i.e. red
|
||||
|
@ -137,11 +137,11 @@ Field::Field(GUI::Label& flag_label, GUI::Label& time_label, GUI::Button& face_b
|
|||
set_face(Face::Default);
|
||||
|
||||
{
|
||||
bool single_chording = Config::read_bool("Minesweeper", "Game", "SingleChording", false);
|
||||
int mine_count = Config::read_i32("Minesweeper", "Game", "MineCount", 10);
|
||||
int rows = Config::read_i32("Minesweeper", "Game", "Rows", 9);
|
||||
int columns = Config::read_i32("Minesweeper", "Game", "Columns", 9);
|
||||
auto difficulty_string = Config::read_string("Minesweeper", "Game", "Difficulty", "beginner");
|
||||
bool single_chording = Config::read_bool("Minesweeper"sv, "Game"sv, "SingleChording"sv, false);
|
||||
int mine_count = Config::read_i32("Minesweeper"sv, "Game"sv, "MineCount"sv, 10);
|
||||
int rows = Config::read_i32("Minesweeper"sv, "Game"sv, "Rows"sv, 9);
|
||||
int columns = Config::read_i32("Minesweeper"sv, "Game"sv, "Columns"sv, 9);
|
||||
auto difficulty_string = Config::read_string("Minesweeper"sv, "Game"sv, "Difficulty"sv, "beginner"sv);
|
||||
auto difficulty = difficulty_from_string(difficulty_string);
|
||||
|
||||
// Do a quick sanity check to make sure the user hasn't tried anything crazy
|
||||
|
@ -507,10 +507,10 @@ void Field::set_field_size(Difficulty difficulty, size_t rows, size_t columns, s
|
|||
if (m_rows == rows && m_columns == columns && m_mine_count == mine_count)
|
||||
return;
|
||||
{
|
||||
Config::write_i32("Minesweeper", "Game", "MineCount", mine_count);
|
||||
Config::write_i32("Minesweeper", "Game", "Rows", rows);
|
||||
Config::write_i32("Minesweeper", "Game", "Columns", columns);
|
||||
Config::write_string("Minesweeper", "Game", "Difficulty", difficulty_to_string(difficulty));
|
||||
Config::write_i32("Minesweeper"sv, "Game"sv, "MineCount"sv, mine_count);
|
||||
Config::write_i32("Minesweeper"sv, "Game"sv, "Rows"sv, rows);
|
||||
Config::write_i32("Minesweeper"sv, "Game"sv, "Columns"sv, columns);
|
||||
Config::write_string("Minesweeper"sv, "Game"sv, "Difficulty"sv, difficulty_to_string(difficulty));
|
||||
}
|
||||
m_difficulty = difficulty;
|
||||
m_rows = rows;
|
||||
|
@ -524,7 +524,7 @@ void Field::set_field_size(Difficulty difficulty, size_t rows, size_t columns, s
|
|||
void Field::set_single_chording(bool enabled)
|
||||
{
|
||||
m_single_chording = enabled;
|
||||
Config::write_bool("Minesweeper", "Game", "SingleChording", m_single_chording);
|
||||
Config::write_bool("Minesweeper"sv, "Game"sv, "SingleChording"sv, m_single_chording);
|
||||
}
|
||||
|
||||
template<typename Callback>
|
||||
|
|
|
@ -74,19 +74,19 @@ public:
|
|||
|
||||
Optional<Difficulty> difficulty_from_string(StringView difficulty_string) const
|
||||
{
|
||||
if (difficulty_string.matches("beginner"))
|
||||
if (difficulty_string.matches("beginner"sv))
|
||||
return Difficulty::Beginner;
|
||||
|
||||
if (difficulty_string.equals_ignoring_case("intermediate"))
|
||||
if (difficulty_string.equals_ignoring_case("intermediate"sv))
|
||||
return Difficulty::Intermediate;
|
||||
|
||||
if (difficulty_string.equals_ignoring_case("expert"))
|
||||
if (difficulty_string.equals_ignoring_case("expert"sv))
|
||||
return Difficulty::Expert;
|
||||
|
||||
if (difficulty_string.equals_ignoring_case("madwoman"))
|
||||
if (difficulty_string.equals_ignoring_case("madwoman"sv))
|
||||
return Difficulty::Madwoman;
|
||||
|
||||
if (difficulty_string.equals_ignoring_case("custom"))
|
||||
if (difficulty_string.equals_ignoring_case("custom"sv))
|
||||
return Difficulty::Custom;
|
||||
|
||||
return {};
|
||||
|
|
|
@ -41,7 +41,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
TRY(Core::System::unveil("/tmp/portal/launch", "rw"));
|
||||
TRY(Core::System::unveil(nullptr, nullptr));
|
||||
|
||||
auto app_icon = TRY(GUI::Icon::try_create_default_icon("app-minesweeper"));
|
||||
auto app_icon = TRY(GUI::Icon::try_create_default_icon("app-minesweeper"sv));
|
||||
|
||||
auto window = TRY(GUI::Window::try_create());
|
||||
window->set_resizable(false);
|
||||
|
@ -63,7 +63,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
container->layout()->add_spacer();
|
||||
|
||||
auto flag_image = TRY(container->try_add<GUI::Label>());
|
||||
flag_image->set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/minesweeper/flag.png").release_value_but_fixme_should_propagate_errors());
|
||||
flag_image->set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/minesweeper/flag.png"sv).release_value_but_fixme_should_propagate_errors());
|
||||
flag_image->set_fixed_width(16);
|
||||
|
||||
auto flag_label = TRY(container->try_add<GUI::Label>());
|
||||
|
@ -81,7 +81,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
|
||||
auto time_image = TRY(container->try_add<GUI::Label>());
|
||||
time_image->set_fixed_width(16);
|
||||
time_image->set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/minesweeper/timer.png").release_value_but_fixme_should_propagate_errors());
|
||||
time_image->set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/minesweeper/timer.png"sv).release_value_but_fixme_should_propagate_errors());
|
||||
|
||||
auto time_label = TRY(container->try_add<GUI::Label>());
|
||||
time_label->set_fixed_width(50);
|
||||
|
@ -96,7 +96,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
|
||||
auto game_menu = TRY(window->try_add_menu("&Game"));
|
||||
|
||||
TRY(game_menu->try_add_action(GUI::Action::create("&New Game", { Mod_None, Key_F2 }, TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/reload.png")), [&](auto&) {
|
||||
TRY(game_menu->try_add_action(GUI::Action::create("&New Game", { Mod_None, Key_F2 }, TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/reload.png"sv)), [&](auto&) {
|
||||
field->reset();
|
||||
})));
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue