AK+LibURL+LibWeb: Use simdutf to validate ASCII strings

simdutf provides a vectorized ASCII validator, so let's use that instead
of looping over strings manually.
This commit is contained in:
Timothy Flynn 2025-04-06 08:39:05 -04:00 committed by Tim Flynn
commit ee6b2db009
Notes: github-actions[bot] 2025-04-06 15:06:55 +00:00
10 changed files with 32 additions and 11 deletions

View file

@ -196,7 +196,7 @@ Optional<String> Host::public_suffix() const
auto public_suffix = get_public_suffix(host_string.bytes_as_string_view()).value_or("*"_string);
// 4. Assert: publicSuffix is an ASCII string that does not end with ".".
VERIFY(all_of(public_suffix.code_points(), is_ascii));
VERIFY(public_suffix.is_ascii());
VERIFY(!public_suffix.ends_with('.'));
// 5. Return publicSuffix and trailingDot concatenated.
@ -223,7 +223,7 @@ Optional<String> Host::registrable_domain() const
auto registrable_domain = get_registrable_domain(host_string).value_or("*"_string);
// 4. Assert: registrableDomain is an ASCII string that does not end with ".".
VERIFY(all_of(registrable_domain.code_points(), is_ascii));
VERIFY(registrable_domain.is_ascii());
VERIFY(!registrable_domain.ends_with('.'));
// 5. Return registrableDomain and trailingDot concatenated.