mirror of
https://github.com/RGBCube/serenity
synced 2025-10-27 07:42:07 +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.
|
||
|---|---|---|
| .. | ||
| Heap | ||
| Runtime | ||
| Tests | ||
| AST.cpp | ||
| AST.h | ||
| CMakeLists.txt | ||
| Console.cpp | ||
| Console.h | ||
| Forward.h | ||
| Interpreter.cpp | ||
| Interpreter.h | ||
| Lexer.cpp | ||
| Lexer.h | ||
| MarkupGenerator.cpp | ||
| MarkupGenerator.h | ||
| Parser.cpp | ||
| Parser.h | ||
| Token.cpp | ||
| Token.h | ||