mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-05-14 10:59:24 +02: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:
committed by
Andreas Kling
parent
ea77092100
commit
2ef2e75cdc
Notes:
github-actions[bot]
2025-05-03 06:09:05 +00:00
Author: https://github.com/awesomekling Commit: https://github.com/LadybirdBrowser/ladybird/commit/2ef2e75cdcb Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/4559
@@ -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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user