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

@ -689,7 +689,7 @@ void Terminal::IL(Parameters params)
void Terminal::DA(Parameters)
{
emit_string("\033[?1;0c");
emit_string("\033[?1;0c"sv);
}
void Terminal::DL(Parameters params)
@ -959,7 +959,7 @@ void Terminal::DSR(Parameters params)
{
if (params.size() == 1 && params[0] == 5) {
// Device status
emit_string("\033[0n"); // Terminal status OK!
emit_string("\033[0n"sv); // Terminal status OK!
} else if (params.size() == 1 && params[0] == 6) {
// Cursor position query
StringBuilder builder;
@ -1388,7 +1388,7 @@ void Terminal::handle_key_press(KeyCode key, u32 code_point, u8 flags)
case KeyCode::Key_Return:
// The standard says that CR should be generated by the return key.
// The TTY will take care of translating it to CR LF for the terminal.
emit_string("\r");
emit_string("\r"sv);
return;
default:
break;
@ -1400,7 +1400,7 @@ void Terminal::handle_key_press(KeyCode key, u32 code_point, u8 flags)
}
if (shift && key == KeyCode::Key_Tab) {
emit_string("\033[Z");
emit_string("\033[Z"sv);
return;
}
@ -1416,7 +1416,7 @@ void Terminal::handle_key_press(KeyCode key, u32 code_point, u8 flags)
// Alt modifier sends escape prefix.
if (alt)
emit_string("\033");
emit_string("\033"sv);
StringBuilder sb;
sb.append_code_point(code_point);
@ -1433,7 +1433,7 @@ void Terminal::unimplemented_escape_sequence(Intermediates intermediates, u8 las
StringBuilder builder;
builder.appendff("Unimplemented escape sequence {:c}", last_byte);
if (!intermediates.is_empty()) {
builder.append(", intermediates: ");
builder.append(", intermediates: "sv);
for (size_t i = 0; i < intermediates.size(); ++i)
builder.append((char)intermediates[i]);
}
@ -1445,13 +1445,13 @@ void Terminal::unimplemented_csi_sequence(Parameters parameters, Intermediates i
StringBuilder builder;
builder.appendff("Unimplemented CSI sequence: {:c}", last_byte);
if (!parameters.is_empty()) {
builder.append(", parameters: [");
builder.append(", parameters: ["sv);
for (size_t i = 0; i < parameters.size(); ++i)
builder.appendff("{}{}", (i == 0) ? "" : ", ", parameters[i]);
builder.append("]");
}
if (!intermediates.is_empty()) {
builder.append(", intermediates:");
builder.append(", intermediates:"sv);
for (size_t i = 0; i < intermediates.size(); ++i)
builder.append((char)intermediates[i]);
}
@ -1465,15 +1465,15 @@ void Terminal::unimplemented_osc_sequence(OscParameters parameters, u8 last_byte
bool first = true;
for (auto parameter : parameters) {
if (!first)
builder.append(", ");
builder.append("[");
builder.append(", "sv);
builder.append('[');
for (auto character : parameter)
builder.append((char)character);
builder.append("]");
first = false;
}
builder.append(" ]");
builder.append(" ]"sv);
dbgln("{}", builder.string_view());
}

View file

@ -97,9 +97,7 @@ TerminalWidget::TerminalWidget(int ptm_fd, bool automatic_size_policy)
update();
};
m_cursor_blink_timer->set_interval(Config::read_i32("Terminal", "Text",
"CursorBlinkInterval",
500));
m_cursor_blink_timer->set_interval(Config::read_i32("Terminal"sv, "Text"sv, "CursorBlinkInterval"sv, 500));
m_cursor_blink_timer->on_timeout = [this] {
m_cursor_blink_state = !m_cursor_blink_state;
update_cursor();
@ -114,7 +112,7 @@ TerminalWidget::TerminalWidget(int ptm_fd, bool automatic_size_policy)
};
m_auto_scroll_timer->start();
auto font_entry = Config::read_string("Terminal", "Text", "Font", "default");
auto font_entry = Config::read_string("Terminal"sv, "Text"sv, "Font"sv, "default"sv);
if (font_entry == "default")
set_font(Gfx::FontDatabase::default_fixed_width_font());
else
@ -122,14 +120,14 @@ TerminalWidget::TerminalWidget(int ptm_fd, bool automatic_size_policy)
m_line_height = font().glyph_height() + m_line_spacing;
m_terminal.set_size(Config::read_i32("Terminal", "Window", "Width", 80), Config::read_i32("Terminal", "Window", "Height", 25));
m_terminal.set_size(Config::read_i32("Terminal"sv, "Window"sv, "Width"sv, 80), Config::read_i32("Terminal"sv, "Window"sv, "Height"sv, 25));
m_copy_action = GUI::Action::create("&Copy", { Mod_Ctrl | Mod_Shift, Key_C }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/edit-copy.png").release_value_but_fixme_should_propagate_errors(), [this](auto&) {
m_copy_action = GUI::Action::create("&Copy", { Mod_Ctrl | Mod_Shift, Key_C }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/edit-copy.png"sv).release_value_but_fixme_should_propagate_errors(), [this](auto&) {
copy();
});
m_copy_action->set_swallow_key_event_when_disabled(true);
m_paste_action = GUI::Action::create("&Paste", { Mod_Ctrl | Mod_Shift, Key_V }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/paste.png").release_value_but_fixme_should_propagate_errors(), [this](auto&) {
m_paste_action = GUI::Action::create("&Paste", { Mod_Ctrl | Mod_Shift, Key_V }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/paste.png"sv).release_value_but_fixme_should_propagate_errors(), [this](auto&) {
paste();
});
m_paste_action->set_swallow_key_event_when_disabled(true);
@ -147,7 +145,7 @@ TerminalWidget::TerminalWidget(int ptm_fd, bool automatic_size_policy)
update_copy_action();
update_paste_action();
set_color_scheme(Config::read_string("Terminal", "Window", "ColorScheme", "Default"));
set_color_scheme(Config::read_string("Terminal"sv, "Window"sv, "ColorScheme"sv, "Default"sv));
}
Gfx::IntRect TerminalWidget::glyph_rect(u16 row, u16 column)
@ -757,7 +755,7 @@ void TerminalWidget::paste()
return;
auto [data, mime_type, _] = GUI::Clipboard::the().fetch_data_and_type();
if (!mime_type.starts_with("text/"))
if (!mime_type.starts_with("text/"sv))
return;
if (data.is_empty())
return;
@ -1170,7 +1168,7 @@ void TerminalWidget::update_copy_action()
void TerminalWidget::update_paste_action()
{
auto [data, mime_type, _] = GUI::Clipboard::the().fetch_data_and_type();
m_paste_action->set_enabled(mime_type.starts_with("text/") && !data.is_empty());
m_paste_action->set_enabled(mime_type.starts_with("text/"sv) && !data.is_empty());
}
void TerminalWidget::set_color_scheme(StringView name)
@ -1183,14 +1181,14 @@ void TerminalWidget::set_color_scheme(StringView name)
m_color_scheme_name = name;
constexpr StringView color_names[] = {
"Black",
"Red",
"Green",
"Yellow",
"Blue",
"Magenta",
"Cyan",
"White"
"Black"sv,
"Red"sv,
"Green"sv,
"Yellow"sv,
"Blue"sv,
"Magenta"sv,
"Cyan"sv,
"White"sv
};
auto path = String::formatted("/res/terminal-colors/{}.ini", name);
@ -1270,8 +1268,8 @@ void TerminalWidget::set_font_and_resize_to_fit(Gfx::Font const& font)
// This basically wraps the code that handles sending the escape sequence in bracketed paste mode.
void TerminalWidget::send_non_user_input(ReadonlyBytes bytes)
{
constexpr StringView leading_control_sequence = "\e[200~";
constexpr StringView trailing_control_sequence = "\e[201~";
constexpr StringView leading_control_sequence = "\e[200~"sv;
constexpr StringView trailing_control_sequence = "\e[201~"sv;
int nwritten;
if (m_terminal.needs_bracketed_paste()) {