LibJS: Add and use PrimitiveString::length_in_utf16_code_units

I was investigating an optimization in this area, and while it
didn't seem to have a noticable improvement, it still seems
useful to apply this change.
This commit is contained in:
Shannon Booth 2025-05-04 00:06:34 +12:00 committed by Andreas Kling
parent 560317b3d0
commit e476d21ed0
Notes: github-actions[bot] 2025-05-03 14:19:42 +00:00
5 changed files with 12 additions and 9 deletions

View file

@ -921,7 +921,7 @@ WebIDL::ExceptionOr<ErrorOr<JS::Value>> evaluate_key_path_on_a_value(JS::Realm&
// If Type(value) is String, and identifier is "length"
if (value.is_string() && identifier == "length") {
// Let value be a Number equal to the number of elements in value.
value = JS::Value(value.as_string().utf16_string_view().length_in_code_units());
value = JS::Value(value.as_string().length_in_utf16_code_units());
}
// If value is an Array and identifier is "length"