1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 20:47:45 +00:00

AK+GMLCompiler+LibWeb: Remove JsonValue::is_double

This concludes a series of patches which remove the ability to observe
which arithmetic type is used to store number in JsonValue.
This commit is contained in:
Dan Klishch 2023-11-14 01:15:54 -05:00 committed by Andrew Kaster
parent faef802229
commit c49819cced
5 changed files with 6 additions and 21 deletions

View file

@ -241,14 +241,6 @@ bool JsonObject::has_object(StringView key) const
return value.has_value() && value->is_object();
}
#ifndef KERNEL
bool JsonObject::has_double(StringView key) const
{
auto value = get(key);
return value.has_value() && value->is_double();
}
#endif
void JsonObject::set(ByteString const& key, JsonValue value)
{
m_members.set(key, move(value));

View file

@ -51,9 +51,6 @@ public:
[[nodiscard]] bool has_number(StringView key) const;
[[nodiscard]] bool has_array(StringView key) const;
[[nodiscard]] bool has_object(StringView key) const;
#ifndef KERNEL
[[nodiscard]] bool has_double(StringView key) const;
#endif
Optional<JsonValue const&> get(StringView key) const;

View file

@ -182,11 +182,6 @@ public:
bool is_null() const { return m_type == Type::Null; }
bool is_bool() const { return m_type == Type::Bool; }
bool is_string() const { return m_type == Type::String; }
bool is_i32() const { return m_type == Type::Int32; }
bool is_u32() const { return m_type == Type::UnsignedInt32; }
bool is_i64() const { return m_type == Type::Int64; }
bool is_u64() const { return m_type == Type::UnsignedInt64; }
bool is_double() const { return m_type == Type::Double; }
bool is_array() const { return m_type == Type::Array; }
bool is_object() const { return m_type == Type::Object; }
bool is_number() const
@ -206,7 +201,7 @@ public:
template<typename T>
T to_number(T default_value = 0) const
{
if (is_double())
if (type() == Type::Double)
return (T)m_value.as_double;
if (type() == Type::Int32)
return (T)m_value.as_i32;