mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-10-23 08:30:50 +00:00
AK+LibJS+LibWeb: Use simdutf to create well-formed strings
This commit is contained in:
parent
017a6cc687
commit
1375e6bf39
Notes:
github-actions[bot]
2025-07-25 22:41:55 +00:00
Author: https://github.com/trflynn89
Commit: 1375e6bf39
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/5608
Reviewed-by: https://github.com/gmta ✅
9 changed files with 37 additions and 42 deletions
|
@ -158,6 +158,16 @@ NonnullRefPtr<Utf16StringData> Utf16StringData::from_string_builder(StringBuilde
|
|||
return adopt_ref(*new (buffer->buffer.data()) Utf16StringData { storage_type, code_unit_length });
|
||||
}
|
||||
|
||||
NonnullRefPtr<Utf16StringData> Utf16StringData::to_well_formed(Utf16View const& utf16_string)
|
||||
{
|
||||
VERIFY(!utf16_string.has_ascii_storage());
|
||||
|
||||
auto string = create_uninitialized(StorageType::UTF16, utf16_string.length_in_code_units());
|
||||
simdutf::to_well_formed_utf16(utf16_string.utf16_span().data(), utf16_string.length_in_code_units(), string->m_utf16_data);
|
||||
|
||||
return string;
|
||||
}
|
||||
|
||||
size_t Utf16StringData::calculate_code_point_length() const
|
||||
{
|
||||
ASSERT(!has_ascii_storage());
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue