summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibJS/Runtime/AbstractOperations.cpp
diff options
context:
space:
mode:
authorTimothy Flynn <trflynn89@pm.me>2022-03-09 15:34:06 -0500
committerAndreas Kling <kling@serenityos.org>2022-03-14 16:33:15 +0100
commitf37fbcf516ccb26e56c14ebdd0c248e8416580e9 (patch)
tree4d4287ae775752e5cd61601f827254d19f2cdaf6 /Userland/Libraries/LibJS/Runtime/AbstractOperations.cpp
parentc12cfe83b72c8dab2bf0779acf906ce8ea0373d3 (diff)
downloadserenity-f37fbcf516ccb26e56c14ebdd0c248e8416580e9.zip
LibJS: Preallocate the list returned from CreateListFromArrayLike
This list has up to 10,000 elements in some test262 tests, so let's avoid frequent allocation bumps.
Diffstat (limited to 'Userland/Libraries/LibJS/Runtime/AbstractOperations.cpp')
-rw-r--r--Userland/Libraries/LibJS/Runtime/AbstractOperations.cpp3
1 files changed, 2 insertions, 1 deletions
diff --git a/Userland/Libraries/LibJS/Runtime/AbstractOperations.cpp b/Userland/Libraries/LibJS/Runtime/AbstractOperations.cpp
index f275d58c84..09f3d241ac 100644
--- a/Userland/Libraries/LibJS/Runtime/AbstractOperations.cpp
+++ b/Userland/Libraries/LibJS/Runtime/AbstractOperations.cpp
@@ -115,6 +115,7 @@ ThrowCompletionOr<MarkedVector<Value>> create_list_from_array_like(GlobalObject&
// 4. Let list be a new empty List.
auto list = MarkedVector<Value> { heap };
+ list.ensure_capacity(length);
// 5. Let index be 0.
// 6. Repeat, while index < len,
@@ -130,7 +131,7 @@ ThrowCompletionOr<MarkedVector<Value>> create_list_from_array_like(GlobalObject&
TRY(check_value(next));
// d. Append next as the last element of list.
- list.append(next);
+ list.unchecked_append(next);
}
// 7. Return list.