Skip to content

Commit 2a87cc5

Browse files
committed
Stop using CollectionIterator in MsgPackSerializer
This doesn't reduce code size or stack usage, but as least it's consistent with `JsonSerializer`.
1 parent 296fe79 commit 2a87cc5

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

src/ArduinoJson/MsgPack/MsgPackSerializer.hpp

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,14 @@ class MsgPackSerializer : public VariantDataVisitor<size_t> {
5959
writeByte(0xDD);
6060
writeInteger(uint32_t(n));
6161
}
62-
for (auto it = array.createIterator(resources_); !it.done();
63-
it.next(resources_)) {
64-
it->accept(*this);
62+
63+
auto slotId = array.head();
64+
while (slotId != NULL_SLOT) {
65+
auto slot = resources_->getSlot(slotId);
66+
slot->data()->accept(*this);
67+
slotId = slot->next();
6568
}
69+
6670
return bytesWritten();
6771
}
6872

@@ -77,11 +81,15 @@ class MsgPackSerializer : public VariantDataVisitor<size_t> {
7781
writeByte(0xDF);
7882
writeInteger(uint32_t(n));
7983
}
80-
for (auto it = object.createIterator(resources_); !it.done();
81-
it.next(resources_)) {
82-
visit(it.key());
83-
it->accept(*this);
84+
85+
auto slotId = object.head();
86+
while (slotId != NULL_SLOT) {
87+
auto slot = resources_->getSlot(slotId);
88+
visit(slot->key());
89+
slot->data()->accept(*this);
90+
slotId = slot->next();
8491
}
92+
8593
return bytesWritten();
8694
}
8795

0 commit comments

Comments
 (0)