mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-06-11 18:20:43 +09:00
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.
This commit is contained in:
parent
c12cfe83b7
commit
f37fbcf516
Notes:
sideshowbarker
2024-07-17 17:27:26 +09:00
Author: https://github.com/trflynn89
Commit: f37fbcf516
Pull-request: https://github.com/SerenityOS/serenity/pull/12976
Reviewed-by: https://github.com/davidot
1 changed files with 2 additions and 1 deletions
|
@ -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.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue