1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-28 13:27:36 +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:
sin-ack 2022-07-11 17:32:29 +00:00 committed by Andreas Kling
parent e5f09ea170
commit 3f3f45580a
762 changed files with 8315 additions and 8316 deletions

View file

@ -76,7 +76,7 @@ void Game::paint_event(GUI::PaintEvent& event)
auto message = String::formatted("Your score: {:.0}\nHigh score: {:.0}\n\n{}", m_last_score, m_high_score.value(), m_restart_cooldown < 0 ? "Press any key to play again" : " ");
painter.draw_text(m_text_rect, message, Gfx::TextAlignment::Center, Color::White);
} else {
painter.draw_text(m_text_rect, "Press any key to start", Gfx::TextAlignment::Center, Color::White);
painter.draw_text(m_text_rect, "Press any key to start"sv, Gfx::TextAlignment::Center, Color::White);
}
}

View file

@ -59,8 +59,8 @@ public:
public:
static ErrorOr<Bug> construct()
{
NonnullRefPtr<Gfx::Bitmap> falling_bitmap = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/flappybug/falling.png"));
NonnullRefPtr<Gfx::Bitmap> flapping_bitmap = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/flappybug/flapping.png"));
NonnullRefPtr<Gfx::Bitmap> falling_bitmap = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/flappybug/falling.png"sv));
NonnullRefPtr<Gfx::Bitmap> flapping_bitmap = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/flappybug/flapping.png"sv));
return Bug(move(falling_bitmap), move(flapping_bitmap));
}
@ -139,9 +139,9 @@ public:
static ErrorOr<Cloud> construct()
{
Vector<NonnullRefPtr<Gfx::Bitmap>> const cloud_bitmaps {
TRY(Gfx::Bitmap::try_load_from_file("/res/icons/flappybug/cloud_0.png")),
TRY(Gfx::Bitmap::try_load_from_file("/res/icons/flappybug/cloud_1.png")),
TRY(Gfx::Bitmap::try_load_from_file("/res/icons/flappybug/cloud_2.png")),
TRY(Gfx::Bitmap::try_load_from_file("/res/icons/flappybug/cloud_0.png"sv)),
TRY(Gfx::Bitmap::try_load_from_file("/res/icons/flappybug/cloud_1.png"sv)),
TRY(Gfx::Bitmap::try_load_from_file("/res/icons/flappybug/cloud_2.png"sv)),
};
return Cloud(move(cloud_bitmaps));
}
@ -173,7 +173,7 @@ private:
float m_last_score {};
float m_difficulty {};
float m_restart_cooldown {};
NonnullRefPtr<Gfx::Bitmap> m_background_bitmap { Gfx::Bitmap::try_load_from_file("/res/icons/flappybug/background.png").release_value_but_fixme_should_propagate_errors() };
NonnullRefPtr<Gfx::Bitmap> m_background_bitmap { Gfx::Bitmap::try_load_from_file("/res/icons/flappybug/background.png"sv).release_value_but_fixme_should_propagate_errors() };
const Gfx::IntRect m_score_rect { 10, 10, 20, 20 };
const Gfx::IntRect m_text_rect { game_width / 2 - 80, game_height / 2 - 40, 160, 80 };

View file

@ -34,11 +34,11 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
TRY(Core::System::unveil("/tmp/portal/launch", "rw"));
TRY(Core::System::unveil(nullptr, nullptr));
u32 high_score = Config::read_i32("FlappyBug", "Game", "HighScore", 0);
u32 high_score = Config::read_i32("FlappyBug"sv, "Game"sv, "HighScore"sv, 0);
auto window = TRY(GUI::Window::try_create());
window->resize(FlappyBug::Game::game_width, FlappyBug::Game::game_height);
auto app_icon = TRY(GUI::Icon::try_create_default_icon("app-flappybug"));
auto app_icon = TRY(GUI::Icon::try_create_default_icon("app-flappybug"sv));
window->set_icon(app_icon.bitmap_for_size(16));
window->set_title("Flappy Bug");
window->set_double_buffering_enabled(false);
@ -49,7 +49,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
if (score <= high_score)
return high_score;
Config::write_i32("FlappyBug", "Game", "HighScore", score);
Config::write_i32("FlappyBug"sv, "Game"sv, "HighScore"sv, score);
high_score = score;
return high_score;