From d3b7c06712f5fce11571f29578087695e5016836 Mon Sep 17 00:00:00 2001 From: Linus Groh Date: Sun, 2 Oct 2022 11:38:52 +0100 Subject: [PATCH] LibJS: Add Value(GCPtr) and Value(NonnullGCPtr) constructors Let's avoid reaching for ptr() as much as possible. --- Userland/Libraries/LibJS/Runtime/Value.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/Userland/Libraries/LibJS/Runtime/Value.h b/Userland/Libraries/LibJS/Runtime/Value.h index aadf403302..b02f05b8f3 100644 --- a/Userland/Libraries/LibJS/Runtime/Value.h +++ b/Userland/Libraries/LibJS/Runtime/Value.h @@ -18,6 +18,7 @@ #include #include #include +#include #include #include #include @@ -275,6 +276,18 @@ public: { } + template + Value(GCPtr ptr) + : Value(ptr.ptr()) + { + } + + template + Value(NonnullGCPtr ptr) + : Value(ptr.ptr()) + { + } + double as_double() const { VERIFY(is_number());