1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-14 09:24:57 +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

@ -114,7 +114,7 @@ StringView FormatParser::consume_literal()
if (consume_specific("}}"))
continue;
if (next_is(is_any_of("{}")))
if (next_is(is_any_of("{}"sv)))
return m_input.substring_view(begin, tell() - begin);
consume();
@ -170,7 +170,7 @@ bool FormatParser::consume_specifier(FormatSpecifier& specifier)
if (!consume_specific('}'))
VERIFY_NOT_REACHED();
specifier.flags = "";
specifier.flags = ""sv;
}
return true;
@ -287,16 +287,16 @@ ErrorOr<void> FormatBuilder::put_u64(
if (prefix) {
if (base == 2) {
if (upper_case)
TRY(m_builder.try_append("0B"));
TRY(m_builder.try_append("0B"sv));
else
TRY(m_builder.try_append("0b"));
TRY(m_builder.try_append("0b"sv));
} else if (base == 8) {
TRY(m_builder.try_append("0"));
TRY(m_builder.try_append("0"sv));
} else if (base == 16) {
if (upper_case)
TRY(m_builder.try_append("0X"));
TRY(m_builder.try_append("0X"sv));
else
TRY(m_builder.try_append("0x"));
TRY(m_builder.try_append("0x"sv));
}
}
return {};
@ -587,8 +587,8 @@ ErrorOr<void> vformat(StringBuilder& builder, StringView fmtstr, TypeErasedForma
void StandardFormatter::parse(TypeErasedFormatParams& params, FormatParser& parser)
{
if (StringView { "<^>" }.contains(parser.peek(1))) {
VERIFY(!parser.next_is(is_any_of("{}")));
if ("<^>"sv.contains(parser.peek(1))) {
VERIFY(!parser.next_is(is_any_of("{}"sv)));
m_fill = parser.consume();
}
@ -788,7 +788,7 @@ ErrorOr<void> Formatter<bool>::format(FormatBuilder& builder, bool value)
return builder.put_hexdump({ &value, sizeof(value) }, m_width.value_or(32), m_fill);
} else {
Formatter<StringView> formatter { *this };
return formatter.format(builder, value ? "true" : "false");
return formatter.format(builder, value ? "true"sv : "false"sv);
}
}
#ifndef KERNEL