mirror of
https://github.com/zebrajr/ladybird.git
synced 2025-12-06 00:19:53 +01:00
AK: Make Utf16View::to_utf8() use simdutf fast path more often
By piggybacking on the already-optimized implementation in StringBuilder, we can get simdutf for the AllowInvalidCodeUnits::Yes case here as well. 1.03x speedup on Speedometer's TodoMVC-jQuery.
This commit is contained in:
parent
f61df9d34c
commit
6efc5c54b5
|
|
@ -168,16 +168,8 @@ ErrorOr<String> Utf16View::to_utf8(AllowInvalidCodeUnits allow_invalid_code_unit
|
|||
return String::from_utf16(*this);
|
||||
|
||||
StringBuilder builder;
|
||||
|
||||
for (size_t i = 0; i < length_in_code_units(); ++i) {
|
||||
auto code_point = code_point_at(i);
|
||||
TRY(builder.try_append_code_point(code_point));
|
||||
|
||||
if (code_point >= first_supplementary_plane_code_point)
|
||||
++i;
|
||||
}
|
||||
|
||||
return builder.to_string_without_validation();
|
||||
builder.append(*this);
|
||||
return builder.to_string();
|
||||
}
|
||||
|
||||
size_t Utf16View::length_in_code_points() const
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user