mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-25 00:50:22 +00:00
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.
This commit is contained in:
parent
50677a58d4
commit
7f224ade60
Notes:
sideshowbarker
2024-07-19 13:27:11 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/7f224ade602
1 changed files with 4 additions and 3 deletions
|
@ -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<StringImpl*>(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;
|
||||
|
|
Loading…
Reference in a new issue