mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-24 18:02:20 +00: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:
parent
47569c1714
commit
5ee810f772
Notes:
github-actions[bot]
2025-05-15 18:13:23 +00:00
Author: https://github.com/kalenikaliaksandr
Commit: 5ee810f772
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/4733
24 changed files with 134 additions and 155 deletions
|
@ -226,7 +226,11 @@ JS_DEFINE_NATIVE_FUNCTION(ReflectObject::own_keys)
|
|||
return vm.throw_completion<TypeError>(ErrorType::NotAnObject, target.to_string_without_side_effects());
|
||||
|
||||
// 2. Let keys be ? target.[[OwnPropertyKeys]]().
|
||||
auto keys = TRY(target.as_object().internal_own_property_keys());
|
||||
auto property_keys = TRY(target.as_object().internal_own_property_keys());
|
||||
GC::RootVector<Value> keys { vm.heap() };
|
||||
keys.ensure_capacity(property_keys.size());
|
||||
for (auto& property_key : property_keys)
|
||||
keys.append(property_key.to_value(vm));
|
||||
|
||||
// 3. Return CreateArrayFromList(keys).
|
||||
return Array::create_from(realm, keys);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue