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

@ -29,7 +29,7 @@ String Color::to_string_without_alpha() const
static Optional<Color> parse_rgb_color(StringView string)
{
VERIFY(string.starts_with("rgb(", CaseSensitivity::CaseInsensitive));
VERIFY(string.starts_with("rgb("sv, CaseSensitivity::CaseInsensitive));
VERIFY(string.ends_with(")"));
auto substring = string.substring_view(4, string.length() - 5);
@ -50,7 +50,7 @@ static Optional<Color> parse_rgb_color(StringView string)
static Optional<Color> parse_rgba_color(StringView string)
{
VERIFY(string.starts_with("rgba(", CaseSensitivity::CaseInsensitive));
VERIFY(string.starts_with("rgba("sv, CaseSensitivity::CaseInsensitive));
VERIFY(string.ends_with(")"));
auto substring = string.substring_view(5, string.length() - 6);
@ -244,7 +244,7 @@ Optional<Color> Color::from_string(StringView string)
{ 0x000000, nullptr }
};
if (string.equals_ignoring_case("transparent"))
if (string.equals_ignoring_case("transparent"sv))
return Color::from_argb(0x00000000);
for (size_t i = 0; !web_colors[i].name.is_null(); ++i) {
@ -252,10 +252,10 @@ Optional<Color> Color::from_string(StringView string)
return Color::from_rgb(web_colors[i].color);
}
if (string.starts_with("rgb(", CaseSensitivity::CaseInsensitive) && string.ends_with(")"))
if (string.starts_with("rgb("sv, CaseSensitivity::CaseInsensitive) && string.ends_with(")"))
return parse_rgb_color(string);
if (string.starts_with("rgba(", CaseSensitivity::CaseInsensitive) && string.ends_with(")"))
if (string.starts_with("rgba("sv, CaseSensitivity::CaseInsensitive) && string.ends_with(")"))
return parse_rgba_color(string);
if (string[0] != '#')