1
0
mirror of https://github.com/esphome/esphome.git synced 2025-09-26 23:22:21 +01:00
This commit is contained in:
J. Nick Koston
2025-08-01 15:26:04 -10:00
parent 8bf3d52fb0
commit 13c749ceda
2 changed files with 8 additions and 10 deletions

View File

@@ -20,18 +20,14 @@ void ComponentIterator::begin(bool include_internal) {
template<typename Container>
void ComponentIterator::process_platform_item_(const Container &items,
bool (ComponentIterator::*on_item)(typename Container::value_type)) {
// Since static_vector doesn't have size(), we need to iterate differently
size_t index = 0;
for (auto *item : items) {
if (index++ == this->at_) {
if ((item->is_internal() && !this->include_internal_) || (this->*on_item)(item)) {
this->at_++;
}
return;
if (this->at_ >= items.size()) {
this->advance_platform_();
} else {
auto *item = items[this->at_];
if ((item->is_internal() && !this->include_internal_) || (this->*on_item)(item)) {
this->at_++;
}
}
// If we get here, we've reached the end
this->advance_platform_();
}
void ComponentIterator::advance_platform_() {

View File

@@ -113,6 +113,8 @@ template<typename T, size_t N> class StaticVector {
}
}
size_t size() const { return count_; }
// For range-based for loops
iterator begin() { return data_.begin(); }
iterator end() { return data_.begin() + count_; }