Skip to content

Commit 509807d

Browse files
committed
Remove CollectionIterator::nextId_
1 parent c07744d commit 509807d

File tree

2 files changed

+9
-14
lines changed

2 files changed

+9
-14
lines changed

src/ArduinoJson/Collection/CollectionData.hpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,11 @@ class CollectionIterator {
5959
}
6060

6161
private:
62-
CollectionIterator(VariantData* slot, SlotId slotId);
62+
CollectionIterator(VariantData* slot, SlotId slotId)
63+
: slot_(slot), currentId_(slotId) {}
6364

6465
VariantData* slot_;
65-
SlotId currentId_, nextId_;
66+
SlotId currentId_;
6667
};
6768

6869
class CollectionData {

src/ArduinoJson/Collection/CollectionImpl.hpp

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,11 @@
1212

1313
ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE
1414

15-
inline CollectionIterator::CollectionIterator(VariantData* slot, SlotId slotId)
16-
: slot_(slot), currentId_(slotId) {
17-
nextId_ = slot_ ? slot_->next() : NULL_SLOT;
18-
}
19-
2015
inline void CollectionIterator::next(const ResourceManager* resources) {
21-
ARDUINOJSON_ASSERT(currentId_ != NULL_SLOT);
22-
slot_ = resources->getVariant(nextId_);
23-
currentId_ = nextId_;
24-
if (slot_)
25-
nextId_ = slot_->next();
16+
ARDUINOJSON_ASSERT(slot_);
17+
auto nextId = slot_->next();
18+
slot_ = resources->getVariant(nextId);
19+
currentId_ = nextId;
2620
}
2721

2822
inline CollectionData::iterator CollectionData::createIterator(
@@ -104,9 +98,9 @@ inline void CollectionData::removePair(ObjectData::iterator it,
10498
if (it.done())
10599
return;
106100

107-
auto keySlot = it.slot_;
101+
auto keySlot = it.data();
108102

109-
auto valueId = it.nextId_;
103+
auto valueId = keySlot->next();
110104
auto valueSlot = resources->getVariant(valueId);
111105

112106
// remove value slot

0 commit comments

Comments
 (0)