mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 08:17: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/Noncopyable.h>
|
||||||
#include <AK/StringView.h>
|
#include <AK/StringView.h>
|
||||||
#include <LibJS/Forward.h>
|
#include <LibJS/Forward.h>
|
||||||
|
#include <LibJS/Heap/GCPtr.h>
|
||||||
|
|
||||||
namespace JS {
|
namespace JS {
|
||||||
|
|
||||||
|
@ -55,6 +56,17 @@ public:
|
||||||
{
|
{
|
||||||
visit_impl(cell);
|
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);
|
void visit(Value);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
|
@ -82,7 +82,7 @@ ThrowCompletionOr<void> FinalizationRegistry::cleanup(Optional<JobCallback> call
|
||||||
void FinalizationRegistry::visit_edges(Cell::Visitor& visitor)
|
void FinalizationRegistry::visit_edges(Cell::Visitor& visitor)
|
||||||
{
|
{
|
||||||
Base::visit_edges(visitor);
|
Base::visit_edges(visitor);
|
||||||
visitor.visit(m_realm.ptr());
|
visitor.visit(m_realm);
|
||||||
for (auto& record : m_records) {
|
for (auto& record : m_records) {
|
||||||
visitor.visit(record.held_value);
|
visitor.visit(record.held_value);
|
||||||
visitor.visit(record.unregister_token);
|
visitor.visit(record.unregister_token);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue