diff options
author | Linus Groh <mail@linusgroh.de> | 2022-10-02 11:40:34 +0100 |
---|---|---|
committer | Linus Groh <mail@linusgroh.de> | 2022-10-02 23:02:27 +0100 |
commit | 0585029c30ce20da06f26d19149d3feccb56ed08 (patch) | |
tree | 51e4f24bb8ba82ed53f11e2d0eb0560328093774 /Userland | |
parent | d3b7c06712f5fce11571f29578087695e5016836 (diff) | |
download | serenity-0585029c30ce20da06f26d19149d3feccb56ed08.zip |
LibJS: Add Visitor::visit(GCPtr<T>) and Visitor::visit(NonnullGCPtr<T>)
Let's avoid reaching for ptr() as much as possible.
Diffstat (limited to 'Userland')
-rw-r--r-- | Userland/Libraries/LibJS/Heap/Cell.h | 12 | ||||
-rw-r--r-- | Userland/Libraries/LibJS/Runtime/FinalizationRegistry.cpp | 2 |
2 files changed, 13 insertions, 1 deletions
diff --git a/Userland/Libraries/LibJS/Heap/Cell.h b/Userland/Libraries/LibJS/Heap/Cell.h index fc266b4ccb..c870a998ee 100644 --- a/Userland/Libraries/LibJS/Heap/Cell.h +++ b/Userland/Libraries/LibJS/Heap/Cell.h @@ -11,6 +11,7 @@ #include <AK/Noncopyable.h> #include <AK/StringView.h> #include <LibJS/Forward.h> +#include <LibJS/Heap/GCPtr.h> namespace JS { @@ -55,6 +56,17 @@ public: { visit_impl(cell); } + template<typename T> + void visit(GCPtr<T> cell) + { + if (cell) + visit_impl(*cell.ptr()); + } + template<typename T> + void visit(NonnullGCPtr<T> cell) + { + visit_impl(*cell.ptr()); + } void visit(Value); protected: diff --git a/Userland/Libraries/LibJS/Runtime/FinalizationRegistry.cpp b/Userland/Libraries/LibJS/Runtime/FinalizationRegistry.cpp index ee63d93006..a11ba51d45 100644 --- a/Userland/Libraries/LibJS/Runtime/FinalizationRegistry.cpp +++ b/Userland/Libraries/LibJS/Runtime/FinalizationRegistry.cpp @@ -82,7 +82,7 @@ ThrowCompletionOr<void> FinalizationRegistry::cleanup(Optional<JobCallback> call void FinalizationRegistry::visit_edges(Cell::Visitor& visitor) { Base::visit_edges(visitor); - visitor.visit(m_realm.ptr()); + visitor.visit(m_realm); for (auto& record : m_records) { visitor.visit(record.held_value); visitor.visit(record.unregister_token); |