Call static clear directly

Before: 9920, 8836, 9742, 12744, 10040
After:  9918, 8796, 9742, 12698,  9994
Target: 9800, 8458, 9634, 12290,  9702
This commit is contained in:
Benoit Blanchon
2025-09-17 09:46:30 +02:00
parent c5d9cf6096
commit 4d13c523ef
6 changed files with 9 additions and 8 deletions

View File

@@ -283,7 +283,7 @@ class JsonDeserializer {
stringBuilder_.save(keyVariant);
} else {
VariantImpl(member, resources_).clear();
VariantImpl::clear(member, resources_);
}
// Parse value

View File

@@ -22,7 +22,7 @@ inline Slot<VariantData> ResourceManager::allocVariant() {
}
inline void ResourceManager::freeVariant(Slot<VariantData> slot) {
VariantImpl(slot.ptr(), this).clear();
VariantImpl::clear(slot.ptr(), this);
variantPools_.freeSlot(slot);
}

View File

@@ -29,7 +29,7 @@ struct Converter<MsgPackBinary> : private detail::VariantAttorney {
if (!data)
return;
auto resources = getResourceManager(dst);
detail::VariantImpl(data, resources).clear();
detail::VariantImpl::clear(data, resources);
if (src.data()) {
size_t headerSize = src.size() >= 0x10000 ? 5
: src.size() >= 0x100 ? 3

View File

@@ -35,7 +35,7 @@ struct Converter<MsgPackExtension> : private detail::VariantAttorney {
if (!data)
return;
auto resources = getResourceManager(dst);
detail::VariantImpl(data, resources).clear();
detail::VariantImpl::clear(data, resources);
if (src.data()) {
uint8_t format, sizeBytes;
if (src.size() >= 0x10000) {

View File

@@ -240,7 +240,7 @@ inline void convertToJson(const ::Printable& src, JsonVariant dst) {
auto data = detail::VariantAttorney::getData(dst);
if (!resources || !data)
return;
detail::VariantImpl(data, resources).clear();
detail::VariantImpl::clear(data, resources);
detail::StringBuilderPrint print(resources);
src.printTo(print);
if (print.overflowed())

View File

@@ -44,8 +44,8 @@ inline bool VariantImpl::setString(TAdaptedString value) {
inline void VariantImpl::clear(VariantData* data_,
ResourceManager* resources_) {
if (!data_)
return;
ARDUINOJSON_ASSERT(data_ != nullptr);
ARDUINOJSON_ASSERT(resources_ != nullptr);
if (data_->type & VariantTypeBits::OwnedStringBit)
resources_->dereferenceString(data_->content.asStringNode->data);
@@ -62,6 +62,7 @@ inline void VariantImpl::clear(VariantData* data_,
}
inline void VariantImpl::clear() {
if (data_)
clear(data_, resources_);
}