mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-06-08 05:27:14 +09:00
LibJS: Reduce HashTable rehashing in get_object_property_iterator()
Apply a little ensure_capacity() to avoid excessive rehashing of the property key table when enumerating a large number of properties. 1.23x speedup on MicroBench/for-in-indexed-properties.js
This commit is contained in:
parent
ea77092100
commit
2ef2e75cdc
Notes:
github-actions[bot]
2025-05-03 06:09:05 +00:00
Author: https://github.com/awesomekling
Commit: 2ef2e75cdc
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/4559
1 changed files with 3 additions and 1 deletions
|
@ -1739,7 +1739,9 @@ inline ThrowCompletionOr<Value> get_object_property_iterator(VM& vm, Value value
|
|||
// Collect all keys immediately (invariant no. 5)
|
||||
for (auto object_to_check = GC::Ptr { object.ptr() }; object_to_check && !seen_objects.contains(*object_to_check); object_to_check = TRY(object_to_check->internal_get_prototype_of())) {
|
||||
seen_objects.set(*object_to_check);
|
||||
for (auto& key : TRY(object_to_check->internal_own_property_keys())) {
|
||||
auto keys = TRY(object_to_check->internal_own_property_keys());
|
||||
properties.ensure_capacity(properties.size() + keys.size());
|
||||
for (auto& key : keys) {
|
||||
if (key.is_symbol())
|
||||
continue;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue