From 2a87cc58396ea6b510a7686645a7b6e23fb89745 Mon Sep 17 00:00:00 2001 From: Benoit Blanchon Date: Wed, 31 Jan 2024 17:45:55 +0100 Subject: [PATCH] Stop using `CollectionIterator` in `MsgPackSerializer` This doesn't reduce code size or stack usage, but as least it's consistent with `JsonSerializer`. --- src/ArduinoJson/MsgPack/MsgPackSerializer.hpp | 22 +++++++++++++------ 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/src/ArduinoJson/MsgPack/MsgPackSerializer.hpp b/src/ArduinoJson/MsgPack/MsgPackSerializer.hpp index 5c3fc24e..15c5a0e3 100644 --- a/src/ArduinoJson/MsgPack/MsgPackSerializer.hpp +++ b/src/ArduinoJson/MsgPack/MsgPackSerializer.hpp @@ -59,10 +59,14 @@ class MsgPackSerializer : public VariantDataVisitor { writeByte(0xDD); writeInteger(uint32_t(n)); } - for (auto it = array.createIterator(resources_); !it.done(); - it.next(resources_)) { - it->accept(*this); + + auto slotId = array.head(); + while (slotId != NULL_SLOT) { + auto slot = resources_->getSlot(slotId); + slot->data()->accept(*this); + slotId = slot->next(); } + return bytesWritten(); } @@ -77,11 +81,15 @@ class MsgPackSerializer : public VariantDataVisitor { writeByte(0xDF); writeInteger(uint32_t(n)); } - for (auto it = object.createIterator(resources_); !it.done(); - it.next(resources_)) { - visit(it.key()); - it->accept(*this); + + auto slotId = object.head(); + while (slotId != NULL_SLOT) { + auto slot = resources_->getSlot(slotId); + visit(slot->key()); + slot->data()->accept(*this); + slotId = slot->next(); } + return bytesWritten(); }