1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 08:17:35 +00:00

LibJS: Convert Array::create{,_from}() to NonnullGCPtr

This commit is contained in:
Linus Groh 2022-12-13 20:49:49 +00:00
parent 0c50751c13
commit 91b0123eaf
25 changed files with 60 additions and 60 deletions

View file

@ -21,11 +21,11 @@ class Array : public Object {
JS_OBJECT(Array, Object);
public:
static ThrowCompletionOr<Array*> create(Realm&, u64 length, Object* prototype = nullptr);
static Array* create_from(Realm&, Vector<Value> const&);
static ThrowCompletionOr<NonnullGCPtr<Array>> create(Realm&, u64 length, Object* prototype = nullptr);
static NonnullGCPtr<Array> create_from(Realm&, Vector<Value> const&);
// Non-standard but equivalent to CreateArrayFromList.
template<typename T>
static Array* create_from(Realm& realm, Span<T const> elements, Function<Value(T const&)> map_fn)
static NonnullGCPtr<Array> create_from(Realm& realm, Span<T const> elements, Function<Value(T const&)> map_fn)
{
auto values = MarkedVector<Value> { realm.heap() };
values.ensure_capacity(elements.size());