diff --git a/Userland/Libraries/LibJS/Runtime/IndexedProperties.cpp b/Userland/Libraries/LibJS/Runtime/IndexedProperties.cpp index be63dcc8d59..ff828cb6b8b 100644 --- a/Userland/Libraries/LibJS/Runtime/IndexedProperties.cpp +++ b/Userland/Libraries/LibJS/Runtime/IndexedProperties.cpp @@ -10,7 +10,8 @@ namespace JS { -const u32 SPARSE_ARRAY_HOLE_THRESHOLD = 200; +constexpr const size_t SPARSE_ARRAY_HOLE_THRESHOLD = 200; +constexpr const size_t LENGTH_SETTER_GENERIC_STORAGE_THRESHOLD = 4 * MiB; SimpleIndexedPropertyStorage::SimpleIndexedPropertyStorage(Vector&& initial_values) : m_array_size(initial_values.size()) @@ -313,7 +314,6 @@ void IndexedProperties::append_all(Object* this_object, const IndexedProperties& void IndexedProperties::set_array_like_size(size_t new_size) { - constexpr size_t length_setter_generic_storage_threshold = 4 * MiB; auto current_array_like_size = array_like_size(); // We can't use simple storage for lengths that don't fit in an i32. @@ -321,7 +321,7 @@ void IndexedProperties::set_array_like_size(size_t new_size) // This prevents something like "a = []; a.length = 0x80000000;" from allocating 2G entries. if (m_storage->is_simple_storage() && (new_size > NumericLimits::max() - || (current_array_like_size < length_setter_generic_storage_threshold && new_size > length_setter_generic_storage_threshold))) { + || (current_array_like_size < LENGTH_SETTER_GENERIC_STORAGE_THRESHOLD && new_size > LENGTH_SETTER_GENERIC_STORAGE_THRESHOLD))) { switch_to_generic_storage(); }