LibJS: Ensure keys vector capacity in Object::internal_own_property_keys

12% improvement on MicroBench/object-keys.js
This commit is contained in:
Aliaksandr Kalenik 2025-05-14 15:57:30 +03:00 committed by Alexander Kalenik
parent 5ee810f772
commit 27ba216e3f
Notes: github-actions[bot] 2025-05-15 18:13:17 +00:00

View file

@ -1112,6 +1112,7 @@ ThrowCompletionOr<Vector<PropertyKey>> Object::internal_own_property_keys() cons
{
// 1. Let keys be a new empty List.
Vector<PropertyKey> keys;
keys.ensure_capacity(m_indexed_properties.real_size() + shape().property_count());
// 2. For each own property key P of O such that P is an array index, in ascending numeric index order, do
for (auto const& entry : m_indexed_properties) {