From 021c8dea1fc339c43d2b937978892c8cfffb8e37 Mon Sep 17 00:00:00 2001 From: Linus Groh Date: Sat, 7 Nov 2020 00:18:57 +0000 Subject: [PATCH] LibJS: Skip trailing empty values in IndexedPropertyIterator When we reach the end of the pre-computed indices vector we can just skip to the end (array-like size) as only empty values will follow. Fixes #3970. --- Libraries/LibJS/Runtime/IndexedProperties.cpp | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/Libraries/LibJS/Runtime/IndexedProperties.cpp b/Libraries/LibJS/Runtime/IndexedProperties.cpp index 83a79b9be8..146296287c 100644 --- a/Libraries/LibJS/Runtime/IndexedProperties.cpp +++ b/Libraries/LibJS/Runtime/IndexedProperties.cpp @@ -264,16 +264,13 @@ ValueAndAttributes IndexedPropertyIterator::value_and_attributes(Object* this_ob void IndexedPropertyIterator::skip_empty_indices() { auto indices = m_indexed_properties.indices(); - if (indices.is_empty()) { - m_index = m_indexed_properties.array_like_size(); - return; - } for (auto i : indices) { if (i < m_index) continue; m_index = i; - break; + return; } + m_index = m_indexed_properties.array_like_size(); } Optional IndexedProperties::get(Object* this_object, u32 index, bool evaluate_accessors) const