mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-08 01:00:05 +00:00
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:
parent
560317b3d0
commit
e476d21ed0
Notes:
github-actions[bot]
2025-05-03 14:19:42 +00:00
Author: https://github.com/shannonbooth
Commit: e476d21ed0
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/4571
5 changed files with 12 additions and 9 deletions
|
@ -106,6 +106,11 @@ Utf16View PrimitiveString::utf16_string_view() const
|
|||
return m_utf16_string->view();
|
||||
}
|
||||
|
||||
size_t PrimitiveString::length_in_utf16_code_units() const
|
||||
{
|
||||
return utf16_string_view().length_in_code_units();
|
||||
}
|
||||
|
||||
bool PrimitiveString::operator==(PrimitiveString const& other) const
|
||||
{
|
||||
if (this == &other)
|
||||
|
@ -123,8 +128,7 @@ ThrowCompletionOr<Optional<Value>> PrimitiveString::get(VM& vm, PropertyKey cons
|
|||
return Optional<Value> {};
|
||||
if (property_key.is_string()) {
|
||||
if (property_key.as_string() == vm.names.length.as_string()) {
|
||||
auto length = utf16_string().length_in_code_units();
|
||||
return Value(static_cast<double>(length));
|
||||
return Value(static_cast<double>(length_in_utf16_code_units()));
|
||||
}
|
||||
}
|
||||
auto index = canonical_numeric_index_string(property_key, CanonicalIndexMode::IgnoreNumericRoundtrip);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue