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:
parent
212095e1c2
commit
ee6b2db009
Notes:
github-actions[bot]
2025-04-06 15:06:55 +00:00
Author: https://github.com/trflynn89
Commit: ee6b2db009
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/4252
10 changed files with 32 additions and 11 deletions
|
@ -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();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue