1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 23:37:36 +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:
Linus Groh 2022-10-02 11:40:34 +01:00
parent d3b7c06712
commit 0585029c30
2 changed files with 13 additions and 1 deletions

View file

@ -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: