MsgPackSerializer: use iterators to serialize array and objects

This commit is contained in:
Benoit Blanchon
2025-07-23 16:31:19 +02:00
parent 60a767c706
commit 03da4aad99
2 changed files with 4 additions and 16 deletions

View File

@ -59,12 +59,8 @@ class MsgPackSerializer : public VariantDataVisitor<size_t> {
writeInteger(uint32_t(n)); writeInteger(uint32_t(n));
} }
auto slotId = array.head(); for (auto it = array.createIterator(); !it.done(); it.move())
while (slotId != NULL_SLOT) { it->accept(*this);
auto slot = resources_->getVariant(slotId);
VariantImpl(slot, resources_).accept(*this);
slotId = slot->next;
}
return bytesWritten(); return bytesWritten();
} }
@ -81,12 +77,8 @@ class MsgPackSerializer : public VariantDataVisitor<size_t> {
writeInteger(uint32_t(n)); writeInteger(uint32_t(n));
} }
auto slotId = object.head(); for (auto it = object.createIterator(); !it.done(); it.move())
while (slotId != NULL_SLOT) { it->accept(*this);
auto slot = resources_->getVariant(slotId);
VariantImpl(slot, resources_).accept(*this);
slotId = slot->next;
}
return bytesWritten(); return bytesWritten();
} }

View File

@ -266,10 +266,6 @@ class VariantImpl {
} }
#endif #endif
SlotId head() const {
return getCollectionData()->head;
}
iterator createIterator() const; iterator createIterator() const;
VariantData* getElement(size_t index) const; VariantData* getElement(size_t index) const;