From 373ec387c19761c34f96ad84596d05c65f2cad62 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Fri, 8 Dec 2023 12:37:40 +0100 Subject: [PATCH] LibJS: Add fast_is() --- Userland/Libraries/LibJS/Runtime/ArrayIterator.h | 4 ++++ Userland/Libraries/LibJS/Runtime/Object.h | 1 + 2 files changed, 5 insertions(+) diff --git a/Userland/Libraries/LibJS/Runtime/ArrayIterator.h b/Userland/Libraries/LibJS/Runtime/ArrayIterator.h index 47575633e2c..034d35e3814 100644 --- a/Userland/Libraries/LibJS/Runtime/ArrayIterator.h +++ b/Userland/Libraries/LibJS/Runtime/ArrayIterator.h @@ -28,6 +28,7 @@ private: ArrayIterator(Value array, Object::PropertyKind iteration_kind, Object& prototype); + virtual bool is_array_iterator() const override { return true; } virtual void visit_edges(Cell::Visitor&) override; Value m_array; @@ -35,4 +36,7 @@ private: size_t m_index { 0 }; }; +template<> +inline bool Object::fast_is() const { return is_array_iterator(); } + } diff --git a/Userland/Libraries/LibJS/Runtime/Object.h b/Userland/Libraries/LibJS/Runtime/Object.h index d92ae61f4a4..9b13dc1d2d0 100644 --- a/Userland/Libraries/LibJS/Runtime/Object.h +++ b/Userland/Libraries/LibJS/Runtime/Object.h @@ -191,6 +191,7 @@ public: virtual bool is_native_function() const { return false; } virtual bool is_ecmascript_function_object() const { return false; } virtual bool is_iterator_record() const { return false; } + virtual bool is_array_iterator() const { return false; } // B.3.7 The [[IsHTMLDDA]] Internal Slot, https://tc39.es/ecma262/#sec-IsHTMLDDA-internal-slot virtual bool is_htmldda() const { return false; }