mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 23:47:45 +00:00
LibJS: Add Visitor::visit(GCPtr<T>) and Visitor::visit(NonnullGCPtr<T>)
Let's avoid reaching for ptr() as much as possible.
This commit is contained in:
parent
d3b7c06712
commit
0585029c30
2 changed files with 13 additions and 1 deletions
|
@ -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:
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue