1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 21:17:44 +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

@ -55,16 +55,16 @@ Configuration Configuration::from_config(StringView libname)
configuration.set(flags);
if (refresh.equals_ignoring_case("lazy"))
if (refresh.equals_ignoring_case("lazy"sv))
configuration.set(Configuration::Lazy);
else if (refresh.equals_ignoring_case("eager"))
else if (refresh.equals_ignoring_case("eager"sv))
configuration.set(Configuration::Eager);
if (operation.equals_ignoring_case("full"))
if (operation.equals_ignoring_case("full"sv))
configuration.set(Configuration::OperationMode::Full);
else if (operation.equals_ignoring_case("noescapesequences"))
else if (operation.equals_ignoring_case("noescapesequences"sv))
configuration.set(Configuration::OperationMode::NoEscapeSequences);
else if (operation.equals_ignoring_case("noninteractive"))
else if (operation.equals_ignoring_case("noninteractive"sv))
configuration.set(Configuration::OperationMode::NonInteractive);
else
configuration.set(Configuration::OperationMode::Unset);
@ -125,7 +125,7 @@ Configuration Configuration::from_config(StringView libname)
while (!value_lexer.is_eof())
value_builder.append(value_lexer.consume_escaped_character());
auto value = value_builder.string_view();
if (value.starts_with("internal:")) {
if (value.starts_with("internal:"sv)) {
configuration.set(KeyBinding {
keys,
KeyBinding::Kind::InternalFunction,
@ -258,8 +258,8 @@ bool Editor::load_history(String const& path)
return false;
auto data = history_file->read_all();
auto hist = StringView { data.data(), data.size() };
for (auto& str : hist.split_view("\n\n")) {
auto it = str.find("::").value_or(0);
for (auto& str : hist.split_view("\n\n"sv)) {
auto it = str.find("::"sv).value_or(0);
auto time = str.substring_view(0, it).to_uint<time_t>().value_or(0);
auto string = str.substring_view(it == 0 ? it : it + 2);
m_history.append({ string, time });
@ -320,7 +320,7 @@ bool Editor::save_history(String const& path)
merge(
file->line_begin(), file->line_end(), m_history.begin(), m_history.end(), final_history,
[](StringView str) {
auto it = str.find("::").value_or(0);
auto it = str.find("::"sv).value_or(0);
auto time = str.substring_view(0, it).to_uint<time_t>().value_or(0);
auto string = str.substring_view(it == 0 ? it : it + 2);
return HistoryEntry { string, time };
@ -1676,36 +1676,36 @@ void Style::unify_with(Style const& other, bool prefer_other)
String Style::to_string() const
{
StringBuilder builder;
builder.append("Style { ");
builder.append("Style { "sv);
if (!m_foreground.is_default()) {
builder.append("Foreground(");
builder.append("Foreground("sv);
if (m_foreground.m_is_rgb) {
builder.join(", ", m_foreground.m_rgb_color);
builder.join(", "sv, m_foreground.m_rgb_color);
} else {
builder.appendff("(XtermColor) {}", (int)m_foreground.m_xterm_color);
}
builder.append("), ");
builder.append("), "sv);
}
if (!m_background.is_default()) {
builder.append("Background(");
builder.append("Background("sv);
if (m_background.m_is_rgb) {
builder.join(' ', m_background.m_rgb_color);
} else {
builder.appendff("(XtermColor) {}", (int)m_background.m_xterm_color);
}
builder.append("), ");
builder.append("), "sv);
}
if (bold())
builder.append("Bold, ");
builder.append("Bold, "sv);
if (underline())
builder.append("Underline, ");
builder.append("Underline, "sv);
if (italic())
builder.append("Italic, ");
builder.append("Italic, "sv);
if (!m_hyperlink.is_empty())
builder.appendff("Hyperlink(\"{}\"), ", m_hyperlink.m_link);