mirror of
https://github.com/bblanchon/ArduinoJson.git
synced 2025-09-25 22:40:56 +02:00
Extract toObject()
Before: 9884, 8796, 9702, 12668, 9964 After: 9874, 8796, 9694, 12634, 9970 Target: 9800, 8458, 9634, 12290, 9702
This commit is contained in:
@@ -78,8 +78,8 @@ class JsonDeserializer {
|
|||||||
|
|
||||||
case '{':
|
case '{':
|
||||||
if (filter.allowObject())
|
if (filter.allowObject())
|
||||||
return parseObject(VariantImpl(variant, resources_).toObject(),
|
return parseObject(VariantImpl::toObject(variant, resources_), filter,
|
||||||
filter, nestingLimit);
|
nestingLimit);
|
||||||
else
|
else
|
||||||
return skipObject(nestingLimit);
|
return skipObject(nestingLimit);
|
||||||
|
|
||||||
|
@@ -388,7 +388,7 @@ class MsgPackDeserializer {
|
|||||||
ObjectImpl object;
|
ObjectImpl object;
|
||||||
if (filter.allowObject()) {
|
if (filter.allowObject()) {
|
||||||
ARDUINOJSON_ASSERT(variant != 0);
|
ARDUINOJSON_ASSERT(variant != 0);
|
||||||
object = VariantImpl(variant, resources_).toObject();
|
object = VariantImpl::toObject(variant, resources_);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (; n; --n) {
|
for (; n; --n) {
|
||||||
|
@@ -493,9 +493,15 @@ class VariantImpl {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ObjectImpl toObject() {
|
ObjectImpl toObject() {
|
||||||
ARDUINOJSON_ASSERT(type() == VariantType::Null); // must call clear() first
|
|
||||||
if (!data_)
|
if (!data_)
|
||||||
return ObjectImpl();
|
return ObjectImpl();
|
||||||
|
return toObject(data_, resources_);
|
||||||
|
}
|
||||||
|
|
||||||
|
static ObjectImpl toObject(VariantData* data_, ResourceManager* resources_) {
|
||||||
|
ARDUINOJSON_ASSERT(data_ != nullptr);
|
||||||
|
ARDUINOJSON_ASSERT(data_->type == VariantType::Null);
|
||||||
|
ARDUINOJSON_ASSERT(resources_ != nullptr);
|
||||||
data_->type = VariantType::Object;
|
data_->type = VariantType::Object;
|
||||||
return ObjectImpl(new (&data_->content.asCollection) CollectionData(),
|
return ObjectImpl(new (&data_->content.asCollection) CollectionData(),
|
||||||
resources_);
|
resources_);
|
||||||
|
Reference in New Issue
Block a user