Skip to content

Commit 080c8cb

Browse files
committed
Extract addElement() NO CHANGE
1 parent 0b19724 commit 080c8cb

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/ArduinoJson/Variant/VariantData.hpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,15 @@ class VariantImpl {
111111
ResourceManager* resources_);
112112

113113
VariantData* addElement() {
114-
auto array = isNull() ? toArray() : asArray();
114+
return addElement(data_, resources_);
115+
}
116+
117+
static VariantData* addElement(VariantData* data_,
118+
ResourceManager* resources_) {
119+
if (!data_)
120+
return nullptr;
121+
auto array = data_->type == VariantType::Null ? toArray(data_, resources_)
122+
: asArray(data_, resources_);
115123
return array.addElement();
116124
}
117125

0 commit comments

Comments
 (0)