1
0
Fork 0
mirror of https://github.com/LadybirdBrowser/ladybird.git synced 2025-06-08 05:27:14 +09:00

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
parent 212095e1c2
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

@ -15,6 +15,8 @@
#include <AK/StringView.h>
#include <AK/Vector.h>
#include <simdutf.h>
namespace AK {
StringView::StringView(String const& string)
@ -195,6 +197,13 @@ bool StringView::equals_ignoring_ascii_case(StringView other) const
return StringUtils::equals_ignoring_ascii_case(*this, other);
}
bool StringView::is_ascii() const
{
if (is_empty())
return true;
return simdutf::validate_ascii(characters_without_null_termination(), length());
}
ByteString StringView::to_lowercase_string() const
{
return StringImpl::create_lowercased(characters_without_null_termination(), length()).release_nonnull();