ladybird/Libraries/LibJS/Runtime/BooleanObject.h
Andreas Kling c12f8b80dc LibJS: Add fast_is<T> helpers for all the primitive wrapper objects
The JS runtime is full of checks for is<NumberObject> and friends.
They were showing up in a Speedometer profile as ~1% spent in
dynamic_cast, and this basically chops that down to nothing.
2025-03-25 23:57:00 +00:00

36 lines
724 B
C++

/*
* Copyright (c) 2020, Jack Karamanian <karamanian.jack@gmail.com>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <LibJS/Runtime/Object.h>
namespace JS {
class BooleanObject : public Object {
JS_OBJECT(BooleanObject, Object);
GC_DECLARE_ALLOCATOR(BooleanObject);
public:
static GC::Ref<BooleanObject> create(Realm&, bool);
virtual ~BooleanObject() override = default;
bool boolean() const { return m_value; }
protected:
BooleanObject(bool, Object& prototype);
private:
virtual bool is_boolean_object() const final { return true; }
bool m_value { false };
};
template<>
inline bool Object::fast_is<BooleanObject>() const { return is_boolean_object(); }
}