mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 10:37:45 +00:00
LibJS: Don't punish large arrays with generic indexed property storage
This patch rethinks the way indexed property storage works: Instead of having a cut-off point at 200 elements where we always move to generic property storage, we now allow arrays to stay in simple mode as long as we don't create a gap/hole larger than 200 elements. We also simplify generic storage to only have a hash map (for now) instead of juggling both a vector and a hash map. This is mostly fine since the vast majority of arrays get to stay simple now. This is a huge speedup on anything that uses basic JS arrays with more than 200 elements in them. :^)
This commit is contained in:
parent
dee0c46c9b
commit
d0664ce6c9
3 changed files with 52 additions and 93 deletions
|
@ -25,7 +25,8 @@ describe("normal behavior", () => {
|
|||
test("Issue #5884, GenericIndexedPropertyStorage::take_first() loses elements", () => {
|
||||
const a = [];
|
||||
for (let i = 0; i < 300; i++) {
|
||||
a.push(i);
|
||||
// NOTE: We use defineProperty to prevent the array from using SimpleIndexedPropertyStorage
|
||||
Object.defineProperty(a, i, { value: i, writable: false });
|
||||
}
|
||||
expect(a.length).toBe(300);
|
||||
for (let i = 0; i < 300; i++) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue