From 7f224ade60229f0e6b80085f0451cef384c56458 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Sat, 29 Jun 2019 12:03:53 +0200 Subject: [PATCH] JsonValue: No need to null-check StringImpls if type is Type::String. If you try to create a JsonValue from a null String(), it will become a null JsonValue anyway. --- AK/JsonValue.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/AK/JsonValue.cpp b/AK/JsonValue.cpp index adb796c716..92893040d6 100644 --- a/AK/JsonValue.cpp +++ b/AK/JsonValue.cpp @@ -31,8 +31,9 @@ void JsonValue::copy_from(const JsonValue& other) m_type = other.m_type; switch (m_type) { case Type::String: + ASSERT(!m_value.as_string); m_value.as_string = other.m_value.as_string; - AK::ref_if_not_null(m_value.as_string); + m_value.as_string->ref(); break; case Type::Object: m_value.as_object = new JsonObject(*other.m_value.as_object); @@ -105,7 +106,7 @@ JsonValue::JsonValue(const String& value) } else { m_type = Type::String; m_value.as_string = const_cast(value.impl()); - AK::ref_if_not_null(m_value.as_string); + m_value.as_string->ref(); } } @@ -125,7 +126,7 @@ void JsonValue::clear() { switch (m_type) { case Type::String: - AK::deref_if_not_null(m_value.as_string); + m_value.as_string->deref(); break; case Type::Object: delete m_value.as_object;