Skip to content

Commit f72526c

Browse files
committed
Extract toArray()
Before: 9894, 8796, 9708, 12674, 9970 After: 9884, 8796, 9702, 12668, 9964 Target: 9800, 8458, 9634, 12290, 9702
1 parent a9461f8 commit f72526c

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

src/ArduinoJson/Json/JsonDeserializer.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ class JsonDeserializer {
7171
switch (current()) {
7272
case '[':
7373
if (filter.allowArray())
74-
return parseArray(VariantImpl(variant, resources_).toArray(), filter,
74+
return parseArray(VariantImpl::toArray(variant, resources_), filter,
7575
nestingLimit);
7676
else
7777
return skipArray(nestingLimit);

src/ArduinoJson/MsgPack/MsgPackDeserializer.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@ class MsgPackDeserializer {
352352
ArrayImpl array;
353353
if (allowArray) {
354354
ARDUINOJSON_ASSERT(variant != 0);
355-
array = VariantImpl(variant, resources_).toArray();
355+
array = VariantImpl::toArray(variant, resources_);
356356
}
357357

358358
TFilter elementFilter = filter[0U];

src/ArduinoJson/Variant/VariantData.hpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -478,9 +478,15 @@ class VariantImpl {
478478
}
479479

480480
ArrayImpl toArray() {
481-
ARDUINOJSON_ASSERT(type() == VariantType::Null); // must call clear() first
482481
if (!data_)
483482
return ArrayImpl();
483+
return toArray(data_, resources_);
484+
}
485+
486+
static ArrayImpl toArray(VariantData* data_, ResourceManager* resources_) {
487+
ARDUINOJSON_ASSERT(data_ != nullptr);
488+
ARDUINOJSON_ASSERT(data_->type == VariantType::Null);
489+
ARDUINOJSON_ASSERT(resources_ != nullptr);
484490
data_->type = VariantType::Array;
485491
return ArrayImpl(new (&data_->content.asCollection) CollectionData(),
486492
resources_);

0 commit comments

Comments
 (0)