mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-25 17:25:08 +02:00
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:
committed by
Alexander Kalenik
parent
47569c1714
commit
5ee810f772
Notes:
github-actions[bot]
2025-05-15 18:13:23 +00:00
Author: https://github.com/kalenikaliaksandr Commit: https://github.com/LadybirdBrowser/ladybird/commit/5ee810f7721 Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/4733
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user