Remove CollectionIterator::nextId_

This commit is contained in:
Benoit Blanchon
2025-07-10 19:16:47 +02:00
parent c07744dc0d
commit 509807d3c2
2 changed files with 9 additions and 14 deletions

View File

@ -59,10 +59,11 @@ class CollectionIterator {
}
private:
CollectionIterator(VariantData* slot, SlotId slotId);
CollectionIterator(VariantData* slot, SlotId slotId)
: slot_(slot), currentId_(slotId) {}
VariantData* slot_;
SlotId currentId_, nextId_;
SlotId currentId_;
};
class CollectionData {

View File

@ -12,17 +12,11 @@
ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE
inline CollectionIterator::CollectionIterator(VariantData* slot, SlotId slotId)
: slot_(slot), currentId_(slotId) {
nextId_ = slot_ ? slot_->next() : NULL_SLOT;
}
inline void CollectionIterator::next(const ResourceManager* resources) {
ARDUINOJSON_ASSERT(currentId_ != NULL_SLOT);
slot_ = resources->getVariant(nextId_);
currentId_ = nextId_;
if (slot_)
nextId_ = slot_->next();
ARDUINOJSON_ASSERT(slot_);
auto nextId = slot_->next();
slot_ = resources->getVariant(nextId);
currentId_ = nextId;
}
inline CollectionData::iterator CollectionData::createIterator(
@ -104,9 +98,9 @@ inline void CollectionData::removePair(ObjectData::iterator it,
if (it.done())
return;
auto keySlot = it.slot_;
auto keySlot = it.data();
auto valueId = it.nextId_;
auto valueId = keySlot->next();
auto valueSlot = resources->getVariant(valueId);
// remove value slot