summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLinus Groh <mail@linusgroh.de>2021-05-17 23:13:37 +0100
committerLinus Groh <mail@linusgroh.de>2021-05-17 23:15:18 +0100
commitc15121fef7f1a08614d46bbd5fbbbf4130360a86 (patch)
tree1257f8521b0fd492f087fbb3b916cc852626c210
parent61e132ddfa799db88c4f647741477021a5cc2ffd (diff)
downloadserenity-c15121fef7f1a08614d46bbd5fbbbf4130360a86.zip
LibJS: Make length_setter_generic_storage_threshold a global constant
This was a bit hard to find as a local variable - rename it to uppercase LENGTH_SETTER_GENERIC_STORAGE_THRESHOLD and move it to the top (next to SPARSE_ARRAY_HOLE_THRESHOLD) for good visibility.
-rw-r--r--Userland/Libraries/LibJS/Runtime/IndexedProperties.cpp6
1 files changed, 3 insertions, 3 deletions
diff --git a/Userland/Libraries/LibJS/Runtime/IndexedProperties.cpp b/Userland/Libraries/LibJS/Runtime/IndexedProperties.cpp
index be63dcc8d5..ff828cb6b8 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<Value>&& 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<i32>::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();
}