mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-26 01:35:08 +02:00
LibJS: Skip prototype chain lookup in internal_set() for arrays
...when Array.prototype and Object.prototype are intact.
If `internal_set()` is called on an array exotic object with a numeric
PropertyKey, and:
- the prototype chain has not been modified (i.e., there are no getters
or setters for indexed properties), and
- the array is not the target of a Proxy object,
then we can directly store the value in the receiver's indexed
properties, without checking whether it already exists somewhere in the
prototype chain.
1.7x improvement on the following program:
```js
function f() {
let a = [];
let i = 0;
while (i < 10_000_000) {
a.push(i);
i++;
}
}
f();
```
This commit is contained in:
committed by
Alexander Kalenik
parent
6404f6db57
commit
bd6750aaa5
Notes:
github-actions[bot]
2025-05-23 12:52:28 +00:00
Author: https://github.com/kalenikaliaksandr Commit: https://github.com/LadybirdBrowser/ladybird/commit/bd6750aaa5d Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/4846
@@ -14,11 +14,11 @@ GC_DEFINE_ALLOCATOR(ObservableArray);
|
||||
GC::Ref<ObservableArray> ObservableArray::create(JS::Realm& realm)
|
||||
{
|
||||
auto prototype = realm.intrinsics().array_prototype();
|
||||
return realm.create<ObservableArray>(prototype);
|
||||
return realm.create<ObservableArray>(realm, prototype);
|
||||
}
|
||||
|
||||
ObservableArray::ObservableArray(Object& prototype)
|
||||
: JS::Array(prototype)
|
||||
ObservableArray::ObservableArray(JS::Realm& realm, Object& prototype)
|
||||
: JS::Array(realm, prototype)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user