mirror of
https://github.com/RGBCube/serenity
synced 2026-01-13 01:31:00 +00:00
This provides a huge speed-up for objects with large numbers as property
keys in some situation. Previously we would simply iterate from 0-<max>
and check if there's a non-empty value at each index - now we're being
smarter and compute a list of non-empty indices upfront, by checking
each value in the packed elements vector and appending the sparse
elements hashmap keys (for GenericIndexedPropertyStorage).
Consider this example, an object with a single own property, which is a
number increasing by a factor of 10 each iteration:
for (let i = 0; i < 10; ++i) {
const o = {[10 ** i]: "foo"};
const start = Date.now();
Object.getOwnPropertyNames(o); // <-- IndexedPropertyIterator
const end = Date.now();
console.log(`${10 ** i} -> ${(end - start) / 1000}s`);
}
Before this change:
1 -> 0.0000s
10 -> 0.0000s
100 -> 0.0000s
1000 -> 0.0000s
10000 -> 0.0005s
100000 -> 0.0039s
1000000 -> 0.0295s
10000000 -> 0.2489s
100000000 -> 2.4758s
1000000000 -> 25.5669s
After this change:
1 -> 0.0000s
10 -> 0.0000s
100 -> 0.0000s
1000 -> 0.0000s
10000 -> 0.0000s
100000 -> 0.0000s
1000000 -> 0.0000s
10000000 -> 0.0000s
100000000 -> 0.0000s
1000000000 -> 0.0000s
Fixes #3805.
|
||
|---|---|---|
| .. | ||
| LibAudio | ||
| LibC | ||
| LibChess | ||
| LibCompress | ||
| LibCore | ||
| LibCpp | ||
| LibCrypt | ||
| LibCrypto | ||
| LibDebug | ||
| LibDesktop | ||
| LibDiff | ||
| LibELF | ||
| LibGemini | ||
| LibGfx | ||
| LibGUI | ||
| LibHTTP | ||
| LibImageDecoderClient | ||
| LibIPC | ||
| LibJS | ||
| LibKeyboard | ||
| LibLine | ||
| LibM | ||
| LibMarkdown | ||
| LibPCIDB | ||
| LibProtocol | ||
| LibPthread | ||
| LibTar | ||
| LibTextCodec | ||
| LibThread | ||
| LibTLS | ||
| LibUnwind | ||
| LibVT | ||
| LibWeb | ||
| LibX86 | ||
| CMakeLists.txt | ||