mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-26 14:28:49 +00:00
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.
36 lines
711 B
C++
36 lines
711 B
C++
/*
|
|
* Copyright (c) 2020, Andreas Kling <andreas@ladybird.org>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <LibJS/Runtime/Object.h>
|
|
|
|
namespace JS {
|
|
|
|
class NumberObject : public Object {
|
|
JS_OBJECT(NumberObject, Object);
|
|
GC_DECLARE_ALLOCATOR(NumberObject);
|
|
|
|
public:
|
|
static GC::Ref<NumberObject> create(Realm&, double);
|
|
|
|
virtual ~NumberObject() override = default;
|
|
|
|
double number() const { return m_value; }
|
|
|
|
protected:
|
|
NumberObject(double, Object& prototype);
|
|
|
|
private:
|
|
virtual bool is_number_object() const final { return true; }
|
|
|
|
double m_value { 0 };
|
|
};
|
|
|
|
template<>
|
|
inline bool Object::fast_is<NumberObject>() const { return is_number_object(); }
|
|
|
|
}
|