mirror of
https://github.com/esphome/esphome.git
synced 2026-05-28 04:55:48 +08:00
[core] Inline calculate_looping_components_ into header (#14944)
This commit is contained in:
@@ -394,22 +394,6 @@ void Application::teardown_components(uint32_t timeout_ms) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Application::calculate_looping_components_() {
|
|
||||||
// FixedVector capacity was pre-initialized by codegen with the exact count
|
|
||||||
// of components that override loop(), computed at C++ compile time.
|
|
||||||
|
|
||||||
// Add all components with loop override that aren't already LOOP_DONE
|
|
||||||
// Some components (like logger) may call disable_loop() during initialization
|
|
||||||
// before setup runs, so we need to respect their LOOP_DONE state
|
|
||||||
this->add_looping_components_by_state_(false);
|
|
||||||
|
|
||||||
this->looping_components_active_end_ = this->looping_components_.size();
|
|
||||||
|
|
||||||
// Then add any components that are already LOOP_DONE to the inactive section
|
|
||||||
// This handles components that called disable_loop() during initialization
|
|
||||||
this->add_looping_components_by_state_(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Application::add_looping_components_by_state_(bool match_loop_done) {
|
void Application::add_looping_components_by_state_(bool match_loop_done) {
|
||||||
for (auto *obj : this->components_) {
|
for (auto *obj : this->components_) {
|
||||||
if (obj->has_overridden_loop() &&
|
if (obj->has_overridden_loop() &&
|
||||||
|
|||||||
@@ -595,7 +595,19 @@ class Application {
|
|||||||
|
|
||||||
void register_component_impl_(Component *comp, bool has_loop);
|
void register_component_impl_(Component *comp, bool has_loop);
|
||||||
|
|
||||||
void calculate_looping_components_();
|
void calculate_looping_components_() {
|
||||||
|
// FixedVector capacity was pre-initialized by codegen with the exact count
|
||||||
|
// of components that override loop(), computed at C++ compile time.
|
||||||
|
|
||||||
|
// Add all components with loop override that aren't already LOOP_DONE
|
||||||
|
// Some components (like logger) may call disable_loop() during initialization
|
||||||
|
// before setup runs, so we need to respect their LOOP_DONE state
|
||||||
|
this->add_looping_components_by_state_(false);
|
||||||
|
this->looping_components_active_end_ = this->looping_components_.size();
|
||||||
|
// Then add any components that are already LOOP_DONE to the inactive section
|
||||||
|
// This handles components that called disable_loop() during initialization
|
||||||
|
this->add_looping_components_by_state_(true);
|
||||||
|
}
|
||||||
void add_looping_components_by_state_(bool match_loop_done);
|
void add_looping_components_by_state_(bool match_loop_done);
|
||||||
|
|
||||||
// These methods are called by Component::disable_loop() and Component::enable_loop()
|
// These methods are called by Component::disable_loop() and Component::enable_loop()
|
||||||
|
|||||||
Reference in New Issue
Block a user