From 27ba216e3fd869e0a3bf1d78c3693e5c7993369c Mon Sep 17 00:00:00 2001 From: Aliaksandr Kalenik Date: Wed, 14 May 2025 15:57:30 +0300 Subject: [PATCH] LibJS: Ensure keys vector capacity in Object::internal_own_property_keys 12% improvement on MicroBench/object-keys.js --- Libraries/LibJS/Runtime/Object.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/Libraries/LibJS/Runtime/Object.cpp b/Libraries/LibJS/Runtime/Object.cpp index ae7cc8bac95..fb71d07ef9b 100644 --- a/Libraries/LibJS/Runtime/Object.cpp +++ b/Libraries/LibJS/Runtime/Object.cpp @@ -1112,6 +1112,7 @@ ThrowCompletionOr> Object::internal_own_property_keys() cons { // 1. Let keys be a new empty List. Vector 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) {