LibJS+LibWeb: Return Vector<PropertyKey> from internal_own_property_keys

By doing that we avoid lots of `PropertyKey` -> `Value` -> `PropertyKey`
transforms, which are quite expensive because of underlying
`FlyString` -> `PrimitiveString` -> `FlyString` conversions.

10% improvement on MicroBench/object-keys.js
This commit is contained in:
Aliaksandr Kalenik
2025-05-14 15:39:48 +03:00
committed by Alexander Kalenik
parent 47569c1714
commit 5ee810f772
Notes: github-actions[bot] 2025-05-15 18:13:23 +00:00
24 changed files with 134 additions and 155 deletions

View File

@@ -84,7 +84,8 @@ public:
String to_string() const
{
VERIFY(!is_symbol());
if (is_symbol())
return as_symbol()->descriptive_string().release_value();
if (is_string())
return as_string().to_string();
return String::number(as_number());
@@ -98,6 +99,15 @@ public:
return StringOrSymbol(as_symbol());
}
Value to_value(VM& vm) const
{
if (is_string())
return Value { PrimitiveString::create(vm, as_string()) };
if (is_symbol())
return Value { as_symbol() };
return Value { PrimitiveString::create(vm, String::number(as_number())) };
}
bool operator==(PropertyKey const&) const = default;
private: