mirror of
https://github.com/bblanchon/ArduinoJson.git
synced 2025-09-25 22:40:56 +02:00
Extract toArray()
Before: 9894, 8796, 9708, 12674, 9970 After: 9884, 8796, 9702, 12668, 9964 Target: 9800, 8458, 9634, 12290, 9702
This commit is contained in:
@@ -71,7 +71,7 @@ class JsonDeserializer {
|
|||||||
switch (current()) {
|
switch (current()) {
|
||||||
case '[':
|
case '[':
|
||||||
if (filter.allowArray())
|
if (filter.allowArray())
|
||||||
return parseArray(VariantImpl(variant, resources_).toArray(), filter,
|
return parseArray(VariantImpl::toArray(variant, resources_), filter,
|
||||||
nestingLimit);
|
nestingLimit);
|
||||||
else
|
else
|
||||||
return skipArray(nestingLimit);
|
return skipArray(nestingLimit);
|
||||||
|
@@ -352,7 +352,7 @@ class MsgPackDeserializer {
|
|||||||
ArrayImpl array;
|
ArrayImpl array;
|
||||||
if (allowArray) {
|
if (allowArray) {
|
||||||
ARDUINOJSON_ASSERT(variant != 0);
|
ARDUINOJSON_ASSERT(variant != 0);
|
||||||
array = VariantImpl(variant, resources_).toArray();
|
array = VariantImpl::toArray(variant, resources_);
|
||||||
}
|
}
|
||||||
|
|
||||||
TFilter elementFilter = filter[0U];
|
TFilter elementFilter = filter[0U];
|
||||||
|
@@ -478,9 +478,15 @@ class VariantImpl {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ArrayImpl toArray() {
|
ArrayImpl toArray() {
|
||||||
ARDUINOJSON_ASSERT(type() == VariantType::Null); // must call clear() first
|
|
||||||
if (!data_)
|
if (!data_)
|
||||||
return ArrayImpl();
|
return ArrayImpl();
|
||||||
|
return toArray(data_, resources_);
|
||||||
|
}
|
||||||
|
|
||||||
|
static ArrayImpl toArray(VariantData* data_, ResourceManager* resources_) {
|
||||||
|
ARDUINOJSON_ASSERT(data_ != nullptr);
|
||||||
|
ARDUINOJSON_ASSERT(data_->type == VariantType::Null);
|
||||||
|
ARDUINOJSON_ASSERT(resources_ != nullptr);
|
||||||
data_->type = VariantType::Array;
|
data_->type = VariantType::Array;
|
||||||
return ArrayImpl(new (&data_->content.asCollection) CollectionData(),
|
return ArrayImpl(new (&data_->content.asCollection) CollectionData(),
|
||||||
resources_);
|
resources_);
|
||||||
|
Reference in New Issue
Block a user