From 1c8b70024838e1c62a221f6bd38286b2ebe16299 Mon Sep 17 00:00:00 2001 From: Linus Groh Date: Tue, 13 Dec 2022 20:49:50 +0000 Subject: [PATCH] LibJS: Convert Set::create() to NonnullGCPtr --- Userland/Libraries/LibJS/Runtime/Set.cpp | 6 +++--- Userland/Libraries/LibJS/Runtime/Set.h | 2 +- Userland/Libraries/LibJS/Runtime/SetPrototype.cpp | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Userland/Libraries/LibJS/Runtime/Set.cpp b/Userland/Libraries/LibJS/Runtime/Set.cpp index 120ac92f3f..652c24a2e1 100644 --- a/Userland/Libraries/LibJS/Runtime/Set.cpp +++ b/Userland/Libraries/LibJS/Runtime/Set.cpp @@ -8,9 +8,9 @@ namespace JS { -Set* Set::create(Realm& realm) +NonnullGCPtr Set::create(Realm& realm) { - return realm.heap().allocate(realm, *realm.intrinsics().set_prototype()); + return *realm.heap().allocate(realm, *realm.intrinsics().set_prototype()); } Set::Set(Object& prototype) @@ -29,7 +29,7 @@ NonnullGCPtr Set::copy() const auto& realm = *vm.current_realm(); // FIXME: This is very inefficient, but there's no better way to do this at the moment, as the underlying Map // implementation of m_values uses a non-copyable RedBlackTree. - auto* result = Set::create(realm); + auto result = Set::create(realm); for (auto const& entry : *this) result->set_add(entry.key); return *result; diff --git a/Userland/Libraries/LibJS/Runtime/Set.h b/Userland/Libraries/LibJS/Runtime/Set.h index d855389bdc..fc00ad687e 100644 --- a/Userland/Libraries/LibJS/Runtime/Set.h +++ b/Userland/Libraries/LibJS/Runtime/Set.h @@ -17,7 +17,7 @@ class Set : public Object { JS_OBJECT(Set, Object); public: - static Set* create(Realm&); + static NonnullGCPtr create(Realm&); virtual void initialize(Realm&) override; virtual ~Set() override = default; diff --git a/Userland/Libraries/LibJS/Runtime/SetPrototype.cpp b/Userland/Libraries/LibJS/Runtime/SetPrototype.cpp index fcef496d10..e2f74e8fbd 100644 --- a/Userland/Libraries/LibJS/Runtime/SetPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/SetPrototype.cpp @@ -251,7 +251,7 @@ JS_DEFINE_NATIVE_FUNCTION(SetPrototype::intersection) auto other_record = TRY(get_set_record(vm, vm.argument(0))); // 4. Let resultSetData be a new empty List. - auto* result = Set::create(realm); + auto result = Set::create(realm); // 5. Let thisSize be the number of elements in O.[[SetData]]. auto this_size = set->set_size();