1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-28 06:27:45 +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

@ -60,7 +60,7 @@ ErrorOr<void> HardwareScreenBackend::set_head_mode_setting(GraphicsHeadModeSetti
rc = graphics_connector_set_safe_head_mode_setting(m_framebuffer_fd);
if (rc != 0) {
dbgln("Failed to set backend safe mode setting: aborting");
return Error::from_syscall("graphics_connector_set_safe_head_mode_setting", rc);
return Error::from_syscall("graphics_connector_set_safe_head_mode_setting"sv, rc);
}
dbgln("Failed to set backend mode setting: falling back to safe resolution - success.");
}
@ -83,7 +83,7 @@ ErrorOr<void> HardwareScreenBackend::map_framebuffer()
memset(&mode_setting, 0, sizeof(GraphicsHeadModeSetting));
int rc = graphics_connector_get_head_mode_setting(m_framebuffer_fd, &mode_setting);
if (rc != 0) {
return Error::from_syscall("graphics_connector_get_head_mode_setting", rc);
return Error::from_syscall("graphics_connector_get_head_mode_setting"sv, rc);
}
m_size_in_bytes = mode_setting.horizontal_stride * mode_setting.vertical_active * 2;
m_framebuffer = (Gfx::ARGB32*)TRY(Core::System::mmap(nullptr, m_size_in_bytes, PROT_READ | PROT_WRITE, MAP_SHARED, m_framebuffer_fd, 0));
@ -108,7 +108,7 @@ ErrorOr<GraphicsHeadModeSetting> HardwareScreenBackend::get_head_mode_setting()
memset(&mode_setting, 0, sizeof(GraphicsHeadModeSetting));
int rc = graphics_connector_get_head_mode_setting(m_framebuffer_fd, &mode_setting);
if (rc != 0) {
return Error::from_syscall("graphics_connector_get_head_mode_setting", rc);
return Error::from_syscall("graphics_connector_get_head_mode_setting"sv, rc);
}
m_pitch = mode_setting.horizontal_stride;
return mode_setting;
@ -131,7 +131,7 @@ ErrorOr<void> HardwareScreenBackend::flush_framebuffer_rects(int buffer_index, S
if (rc == -ENOTSUP)
m_can_device_flush_buffers = false;
else if (rc != 0)
return Error::from_syscall("fb_flush_buffers", rc);
return Error::from_syscall("fb_flush_buffers"sv, rc);
return {};
}
@ -141,7 +141,7 @@ ErrorOr<void> HardwareScreenBackend::flush_framebuffer()
if (rc == -ENOTSUP)
m_can_device_flush_entire_framebuffer = false;
else if (rc != 0)
return Error::from_syscall("fb_flush_head", rc);
return Error::from_syscall("fb_flush_head"sv, rc);
return {};
}
}

View file

@ -96,13 +96,13 @@ String KeymapSwitcher::get_current_keymap() const
auto json = JsonValue::from_string(proc_keymap->read_all()).release_value_but_fixme_should_propagate_errors();
auto const& keymap_object = json.as_object();
VERIFY(keymap_object.has("keymap"));
return keymap_object.get("keymap").to_string();
VERIFY(keymap_object.has("keymap"sv));
return keymap_object.get("keymap"sv).to_string();
}
void KeymapSwitcher::setkeymap(const AK::String& keymap)
{
if (Core::Process::spawn("/bin/keymap", Array { "-m", keymap.characters() }).is_error())
if (Core::Process::spawn("/bin/keymap"sv, Array { "-m", keymap.characters() }).is_error())
dbgln("Failed to call /bin/keymap, error: {} ({})", errno, strerror(errno));
if (on_keymap_change)

View file

@ -61,7 +61,7 @@ static constexpr Gfx::CharacterBitmap s_submenu_arrow_bitmap {
" ### "
" ## "
" # "
" ",
" "sv,
9, 9
};
@ -204,9 +204,9 @@ void Menu::draw()
bool can_go_up = m_scroll_offset > 0;
bool can_go_down = m_scroll_offset < m_max_scroll_offset;
Gfx::IntRect up_indicator_rect { frame_thickness(), frame_thickness(), content_width(), item_height() };
painter.draw_text(up_indicator_rect, "\xE2\xAC\x86", Gfx::TextAlignment::Center, can_go_up ? palette.menu_base_text() : palette.color(ColorRole::DisabledText));
painter.draw_text(up_indicator_rect, "\xE2\xAC\x86"sv, Gfx::TextAlignment::Center, can_go_up ? palette.menu_base_text() : palette.color(ColorRole::DisabledText));
Gfx::IntRect down_indicator_rect { frame_thickness(), menu_window()->height() - item_height() - frame_thickness(), content_width(), item_height() };
painter.draw_text(down_indicator_rect, "\xE2\xAC\x87", Gfx::TextAlignment::Center, can_go_down ? palette.menu_base_text() : palette.color(ColorRole::DisabledText));
painter.draw_text(down_indicator_rect, "\xE2\xAC\x87"sv, Gfx::TextAlignment::Center, can_go_down ? palette.menu_base_text() : palette.color(ColorRole::DisabledText));
}
int visible_item_count = this->visible_item_count();

View file

@ -37,7 +37,7 @@ public:
{
#define __ENUMERATE_MODE_ENUM(val) \
case Mode::val: \
return #val;
return #val##sv;
switch (mode) {
__ENUMERATE_MODE_ENUM(Invalid)

View file

@ -38,7 +38,7 @@ static Gfx::Bitmap& minimize_icon()
{
static RefPtr<Gfx::Bitmap> s_icon;
if (!s_icon)
s_icon = Gfx::Bitmap::try_load_from_file("/res/icons/16x16/downward-triangle.png").release_value_but_fixme_should_propagate_errors();
s_icon = Gfx::Bitmap::try_load_from_file("/res/icons/16x16/downward-triangle.png"sv).release_value_but_fixme_should_propagate_errors();
return *s_icon;
}
@ -46,7 +46,7 @@ static Gfx::Bitmap& maximize_icon()
{
static RefPtr<Gfx::Bitmap> s_icon;
if (!s_icon)
s_icon = Gfx::Bitmap::try_load_from_file("/res/icons/16x16/upward-triangle.png").release_value_but_fixme_should_propagate_errors();
s_icon = Gfx::Bitmap::try_load_from_file("/res/icons/16x16/upward-triangle.png"sv).release_value_but_fixme_should_propagate_errors();
return *s_icon;
}
@ -54,7 +54,7 @@ static Gfx::Bitmap& restore_icon()
{
static RefPtr<Gfx::Bitmap> s_icon;
if (!s_icon)
s_icon = Gfx::Bitmap::try_load_from_file("/res/icons/16x16/window-restore.png").release_value_but_fixme_should_propagate_errors();
s_icon = Gfx::Bitmap::try_load_from_file("/res/icons/16x16/window-restore.png"sv).release_value_but_fixme_should_propagate_errors();
return *s_icon;
}
@ -62,7 +62,7 @@ static Gfx::Bitmap& close_icon()
{
static RefPtr<Gfx::Bitmap> s_icon;
if (!s_icon)
s_icon = Gfx::Bitmap::try_load_from_file("/res/icons/16x16/window-close.png").release_value_but_fixme_should_propagate_errors();
s_icon = Gfx::Bitmap::try_load_from_file("/res/icons/16x16/window-close.png"sv).release_value_but_fixme_should_propagate_errors();
return *s_icon;
}
@ -70,7 +70,7 @@ static Gfx::Bitmap& pin_icon()
{
static RefPtr<Gfx::Bitmap> s_icon;
if (!s_icon)
s_icon = Gfx::Bitmap::try_load_from_file("/res/icons/16x16/window-pin.png").release_value_but_fixme_should_propagate_errors();
s_icon = Gfx::Bitmap::try_load_from_file("/res/icons/16x16/window-pin.png"sv).release_value_but_fixme_should_propagate_errors();
return *s_icon;
}
@ -78,7 +78,7 @@ static Gfx::Bitmap& move_icon()
{
static RefPtr<Gfx::Bitmap> s_icon;
if (!s_icon)
s_icon = Gfx::Bitmap::try_load_from_file("/res/icons/16x16/move.png").release_value_but_fixme_should_propagate_errors();
s_icon = Gfx::Bitmap::try_load_from_file("/res/icons/16x16/move.png"sv).release_value_but_fixme_should_propagate_errors();
return *s_icon;
}
@ -1183,7 +1183,7 @@ void Window::set_modified(bool modified)
String Window::computed_title() const
{
String title = m_title.replace("[*]", is_modified() ? " (*)" : "", ReplaceMode::FirstOnly);
String title = m_title.replace("[*]"sv, is_modified() ? " (*)"sv : ""sv, ReplaceMode::FirstOnly);
if (client() && client()->is_unresponsive())
return String::formatted("{} (Not responding)", title);
return title;

View file

@ -142,7 +142,7 @@ void WindowFrame::reload_config()
{
String icons_path = WindowManager::the().palette().title_button_icons_path();
auto reload_bitmap = [&](RefPtr<MultiScaleBitmaps>& multiscale_bitmap, StringView path, StringView default_path = "") {
auto reload_bitmap = [&](RefPtr<MultiScaleBitmaps>& multiscale_bitmap, StringView path, StringView default_path = ""sv) {
StringBuilder full_path;
full_path.append(icons_path);
full_path.append(path);
@ -155,19 +155,19 @@ void WindowFrame::reload_config()
auto reload_icon = [&](Button::Icon& icon, StringView name, StringView default_path) {
StringBuilder full_name;
full_name.append(name);
full_name.append(".png");
full_name.append(".png"sv);
reload_bitmap(icon.bitmap, full_name.string_view(), default_path);
// Note: No default for hover bitmaps
full_name.clear();
full_name.append(name);
full_name.append("-hover.png");
full_name.append("-hover.png"sv);
reload_bitmap(icon.hover_bitmap, full_name.string_view());
};
reload_icon(s_minimize_icon, "window-minimize", "/res/icons/16x16/downward-triangle.png");
reload_icon(s_maximize_icon, "window-maximize", "/res/icons/16x16/upward-triangle.png");
reload_icon(s_restore_icon, "window-restore", "/res/icons/16x16/window-restore.png");
reload_icon(s_close_icon, "window-close", "/res/icons/16x16/window-close.png");
reload_icon(s_close_modified_icon, "window-close-modified", "/res/icons/16x16/window-close-modified.png");
reload_icon(s_minimize_icon, "window-minimize"sv, "/res/icons/16x16/downward-triangle.png"sv);
reload_icon(s_maximize_icon, "window-maximize"sv, "/res/icons/16x16/upward-triangle.png"sv);
reload_icon(s_restore_icon, "window-restore"sv, "/res/icons/16x16/window-restore.png"sv);
reload_icon(s_close_icon, "window-close"sv, "/res/icons/16x16/window-close.png"sv);
reload_icon(s_close_modified_icon, "window-close-modified"sv, "/res/icons/16x16/window-close-modified.png"sv);
auto load_shadow = [](String const& path, String& last_path, RefPtr<MultiScaleBitmaps>& shadow_bitmap) {
if (path.is_empty()) {

View file

@ -2274,7 +2274,7 @@ void WindowManager::apply_cursor_theme(String const& theme_name)
auto reload_cursor = [&](RefPtr<Cursor>& cursor, String const& name) {
bool is_current_cursor = current_cursor && current_cursor == cursor.ptr();
static auto const s_default_cursor_path = "/res/cursor-themes/Default/arrow.x2y2.png";
static auto const s_default_cursor_path = "/res/cursor-themes/Default/arrow.x2y2.png"sv;
cursor = Cursor::create(String::formatted("/res/cursor-themes/{}/{}", theme_name, cursor_theme_config->read_entry("Cursor", name)), s_default_cursor_path);
if (is_current_cursor) {

View file

@ -53,7 +53,7 @@ ErrorOr<int> serenity_main(Main::Arguments)
{
// FIXME: Map switched tty from screens.
// FIXME: Gracefully cleanup the TTY graphics mode.
int tty_fd = TRY(Core::System::open("/dev/tty", O_RDWR));
int tty_fd = TRY(Core::System::open("/dev/tty"sv, O_RDWR));
TRY(Core::System::ioctl(tty_fd, KDSETMODE, KD_GRAPHICS));
TRY(Core::System::close(tty_fd));
}
@ -73,7 +73,7 @@ ErrorOr<int> serenity_main(Main::Arguments)
Core::DirIterator di("/dev/gpu", Core::DirIterator::SkipParentAndBaseDir);
while (di.has_next()) {
auto path = di.next_path();
if (!path.starts_with("connector"))
if (!path.starts_with("connector"sv))
continue;
auto full_path = String::formatted("/dev/gpu/{}", path);
if (!Core::File::is_device(full_path))