1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 20:07:36 +00:00

LibJS: Convert Set::create() to NonnullGCPtr

This commit is contained in:
Linus Groh 2022-12-13 20:49:50 +00:00
parent 9946e9e874
commit 1c8b700248
3 changed files with 5 additions and 5 deletions

View file

@ -8,9 +8,9 @@
namespace JS { namespace JS {
Set* Set::create(Realm& realm) NonnullGCPtr<Set> Set::create(Realm& realm)
{ {
return realm.heap().allocate<Set>(realm, *realm.intrinsics().set_prototype()); return *realm.heap().allocate<Set>(realm, *realm.intrinsics().set_prototype());
} }
Set::Set(Object& prototype) Set::Set(Object& prototype)
@ -29,7 +29,7 @@ NonnullGCPtr<Set> Set::copy() const
auto& realm = *vm.current_realm(); 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 // 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. // implementation of m_values uses a non-copyable RedBlackTree.
auto* result = Set::create(realm); auto result = Set::create(realm);
for (auto const& entry : *this) for (auto const& entry : *this)
result->set_add(entry.key); result->set_add(entry.key);
return *result; return *result;

View file

@ -17,7 +17,7 @@ class Set : public Object {
JS_OBJECT(Set, Object); JS_OBJECT(Set, Object);
public: public:
static Set* create(Realm&); static NonnullGCPtr<Set> create(Realm&);
virtual void initialize(Realm&) override; virtual void initialize(Realm&) override;
virtual ~Set() override = default; virtual ~Set() override = default;

View file

@ -251,7 +251,7 @@ JS_DEFINE_NATIVE_FUNCTION(SetPrototype::intersection)
auto other_record = TRY(get_set_record(vm, vm.argument(0))); auto other_record = TRY(get_set_record(vm, vm.argument(0)));
// 4. Let resultSetData be a new empty List. // 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]]. // 5. Let thisSize be the number of elements in O.[[SetData]].
auto this_size = set->set_size(); auto this_size = set->set_size();