mirror of
https://github.com/bblanchon/ArduinoJson.git
synced 2025-09-26 06:50:56 +02:00
Extract clear()
Before: 10036, 8882, 9742, 12788, 10084 After: 9920, 8836, 9742, 12744, 10040 Target: 9800, 8458, 9634, 12290, 9702
This commit is contained in:
@@ -483,6 +483,8 @@ class VariantImpl {
|
|||||||
// Release the resources used by this variant and set it to null.
|
// Release the resources used by this variant and set it to null.
|
||||||
void clear();
|
void clear();
|
||||||
|
|
||||||
|
static void clear(VariantData* data, ResourceManager* resources);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
VariantData* data_;
|
VariantData* data_;
|
||||||
ResourceManager* resources_;
|
ResourceManager* resources_;
|
||||||
|
@@ -28,7 +28,6 @@ inline bool VariantImpl::setString(TAdaptedString value) {
|
|||||||
if (value.isNull())
|
if (value.isNull())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
|
||||||
if (isTinyString(value, value.size())) {
|
if (isTinyString(value, value.size())) {
|
||||||
data_->setTinyString(value);
|
data_->setTinyString(value);
|
||||||
return true;
|
return true;
|
||||||
@@ -43,7 +42,8 @@ inline bool VariantImpl::setString(TAdaptedString value) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void VariantImpl::clear() {
|
inline void VariantImpl::clear(VariantData* data_,
|
||||||
|
ResourceManager* resources_) {
|
||||||
if (!data_)
|
if (!data_)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -55,11 +55,16 @@ inline void VariantImpl::clear() {
|
|||||||
resources_->freeEightByte(data_->content.asSlotId);
|
resources_->freeEightByte(data_->content.asSlotId);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
asCollection().clear();
|
if (data_->type & VariantTypeBits::CollectionMask)
|
||||||
|
CollectionImpl(&data_->content.asCollection, resources_).clear();
|
||||||
|
|
||||||
data_->type = VariantType::Null;
|
data_->type = VariantType::Null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline void VariantImpl::clear() {
|
||||||
|
clear(data_, resources_);
|
||||||
|
}
|
||||||
|
|
||||||
#if ARDUINOJSON_USE_8_BYTE_POOL
|
#if ARDUINOJSON_USE_8_BYTE_POOL
|
||||||
inline const EightByteValue* VariantImpl::getEightByte() const {
|
inline const EightByteValue* VariantImpl::getEightByte() const {
|
||||||
return type() & VariantTypeBits::EightByteBit
|
return type() & VariantTypeBits::EightByteBit
|
||||||
|
Reference in New Issue
Block a user