mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-12-11 17:00:37 +00:00
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.
This commit is contained in:
parent
61e132ddfa
commit
c15121fef7
Notes:
sideshowbarker
2024-07-18 17:53:56 +09:00
1 changed files with 3 additions and 3 deletions
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue