diff --git a/Userland/Libraries/LibJS/Runtime/Array.cpp b/Userland/Libraries/LibJS/Runtime/Array.cpp index d2ec09a1c31..6c7bf32702e 100644 --- a/Userland/Libraries/LibJS/Runtime/Array.cpp +++ b/Userland/Libraries/LibJS/Runtime/Array.cpp @@ -45,25 +45,7 @@ ThrowCompletionOr> Array::create(Realm& realm, u64 length, O } // 7.3.18 CreateArrayFromList ( elements ), https://tc39.es/ecma262/#sec-createarrayfromlist -NonnullGCPtr Array::create_from(Realm& realm, Vector const& elements) -{ - // 1. Let array be ! ArrayCreate(0). - auto array = MUST(Array::create(realm, 0)); - - // 2. Let n be 0. - // 3. For each element e of elements, do - for (u32 n = 0; n < elements.size(); ++n) { - // a. Perform ! CreateDataPropertyOrThrow(array, ! ToString(𝔽(n)), e). - MUST(array->create_data_property_or_throw(n, elements[n])); - - // b. Set n to n + 1. - } - - // 4. Return array. - return array; -} - -NonnullGCPtr Array::create_from(Realm& realm, ReadonlySpan const& elements) +NonnullGCPtr Array::create_from(Realm& realm, ReadonlySpan elements) { // 1. Let array be ! ArrayCreate(0). auto array = MUST(Array::create(realm, 0)); diff --git a/Userland/Libraries/LibJS/Runtime/Array.h b/Userland/Libraries/LibJS/Runtime/Array.h index 8ba454912ea..a55a2a634d4 100644 --- a/Userland/Libraries/LibJS/Runtime/Array.h +++ b/Userland/Libraries/LibJS/Runtime/Array.h @@ -25,8 +25,7 @@ class Array : public Object { public: static ThrowCompletionOr> create(Realm&, u64 length, Object* prototype = nullptr); - static NonnullGCPtr create_from(Realm&, Vector const&); - static NonnullGCPtr create_from(Realm&, ReadonlySpan const&); + static NonnullGCPtr create_from(Realm&, ReadonlySpan); template static NonnullGCPtr create_from(Realm& realm, Value const (&values)[N])