From 4996753de411493a95d4e32d5c43a0f81ab17f93 Mon Sep 17 00:00:00 2001 From: CarrotzRule123 Date: Thu, 21 Nov 2024 00:15:07 +0800 Subject: [PATCH] fix fast path --- .../indexed_collections/array_objects/array_prototype.rs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/nova_vm/src/ecmascript/builtins/indexed_collections/array_objects/array_prototype.rs b/nova_vm/src/ecmascript/builtins/indexed_collections/array_objects/array_prototype.rs index 0ae591e4..0793d077 100644 --- a/nova_vm/src/ecmascript/builtins/indexed_collections/array_objects/array_prototype.rs +++ b/nova_vm/src/ecmascript/builtins/indexed_collections/array_objects/array_prototype.rs @@ -3116,9 +3116,7 @@ impl ArrayPrototype { let Heap { arrays, elements, .. } = &mut agent.heap; - arrays[array] - .elements - .reserve(elements, len + arg_count as u32); + arrays[array].elements.reserve(elements, final_len.unwrap()); agent[array].elements.len += arg_count as u32; // Fast path: Copy old items to the end of array, // copy new items to the front of the array. @@ -3129,7 +3127,7 @@ impl ArrayPrototype { // The transmute effectively turns Value into Some(Value). std::mem::transmute::<&[Value], &[Option]>(items.0) }); - return Ok(agent[array].elements.len.into()); + return Ok(final_len.unwrap().into()); } } // 1. Let O be ? ToObject(this value).