mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-07 01:21:57 +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
|
@ -236,20 +236,20 @@ JS::ThrowCompletionOr<bool> cross_origin_set(JS::VM& vm, JS::Object& object, JS:
|
|||
}
|
||||
|
||||
// 7.2.3.7 CrossOriginOwnPropertyKeys ( O ), https://html.spec.whatwg.org/multipage/browsers.html#crossoriginownpropertykeys-(-o-)
|
||||
GC::RootVector<JS::Value> cross_origin_own_property_keys(Variant<HTML::Location const*, HTML::Window const*> const& object)
|
||||
Vector<JS::PropertyKey> cross_origin_own_property_keys(Variant<HTML::Location const*, HTML::Window const*> const& object)
|
||||
{
|
||||
auto& event_loop = HTML::main_thread_event_loop();
|
||||
auto& vm = event_loop.vm();
|
||||
|
||||
// 1. Let keys be a new empty List.
|
||||
auto keys = GC::RootVector<JS::Value> { vm.heap() };
|
||||
Vector<JS::PropertyKey> keys;
|
||||
|
||||
// 2. For each e of CrossOriginProperties(O), append e.[[Property]] to keys.
|
||||
for (auto& entry : cross_origin_properties(object))
|
||||
keys.append(JS::PrimitiveString::create(vm, move(entry.property)));
|
||||
keys.append(entry.property);
|
||||
|
||||
// 3. Return the concatenation of keys and « "then", @@toStringTag, @@hasInstance, @@isConcatSpreadable ».
|
||||
keys.append(JS::PrimitiveString::create(vm, vm.names.then.as_string()));
|
||||
keys.append(vm.names.then.as_string());
|
||||
keys.append(vm.well_known_symbol_to_string_tag());
|
||||
keys.append(vm.well_known_symbol_has_instance());
|
||||
keys.append(vm.well_known_symbol_is_concat_spreadable());
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue