summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibWeb/MimeSniff
diff options
context:
space:
mode:
authorsin-ack <sin-ack@users.noreply.github.com>2022-07-11 17:32:29 +0000
committerAndreas Kling <kling@serenityos.org>2022-07-12 23:11:35 +0200
commit3f3f45580ab7266258e97cb3cecf1e24716d61c5 (patch)
tree152c7a187c98184d58bf91a326357e0af435edcf /Userland/Libraries/LibWeb/MimeSniff
parente5f09ea1703bacfbb79a4ad3c587a7d5d3d7bb13 (diff)
downloadserenity-3f3f45580ab7266258e97cb3cecf1e24716d61c5.zip
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.
Diffstat (limited to 'Userland/Libraries/LibWeb/MimeSniff')
-rw-r--r--Userland/Libraries/LibWeb/MimeSniff/MimeType.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/Userland/Libraries/LibWeb/MimeSniff/MimeType.cpp b/Userland/Libraries/LibWeb/MimeSniff/MimeType.cpp
index 7d36522b53..753db70ade 100644
--- a/Userland/Libraries/LibWeb/MimeSniff/MimeType.cpp
+++ b/Userland/Libraries/LibWeb/MimeSniff/MimeType.cpp
@@ -42,7 +42,7 @@ static bool contains_only_http_token_code_points(StringView string)
// https://mimesniff.spec.whatwg.org/#http-token-code-point
// An HTTP token code point is U+0021 (!), U+0023 (#), U+0024 ($), U+0025 (%), U+0026 (&), U+0027 ('), U+002A (*),
// U+002B (+), U+002D (-), U+002E (.), U+005E (^), U+005F (_), U+0060 (`), U+007C (|), U+007E (~), or an ASCII alphanumeric.
- constexpr auto is_certain_non_ascii_alphanumeric = is_any_of("!#$%&'*+-.^_`|~");
+ constexpr auto is_certain_non_ascii_alphanumeric = is_any_of("!#$%&'*+-.^_`|~"sv);
for (char ch : string) {
if (!is_certain_non_ascii_alphanumeric(ch) && !is_ascii_alphanumeric(ch))
return false;
@@ -56,7 +56,7 @@ Optional<MimeType> MimeType::from_string(StringView string)
// https://fetch.spec.whatwg.org/#http-whitespace
// HTTP whitespace is U+000A LF, U+000D CR, or an HTTP tab or space.
// An HTTP tab or space is U+0009 TAB or U+0020 SPACE.
- constexpr char const* http_whitespace = "\n\r\t ";
+ constexpr auto http_whitespace = "\n\r\t "sv;
// 1. Remove any leading and trailing HTTP whitespace from input.
auto trimmed_string = string.trim(http_whitespace, TrimMode::Both);