mirror of
https://github.com/esphome/esphome.git
synced 2026-07-10 08:55:36 +00:00
[core] Call loop() directly in main loop, bypass call() indirection
In the main loop, components in looping_components_ active section are
guaranteed to be in LOOP state. The call() method's state machine
dispatch (checking CONSTRUCTION, SETUP, FAILED, LOOP_DONE) is only
needed during Application::setup(). In the main loop it adds two
unnecessary function call frames per component per iteration
(call() -> call_loop_() -> loop()).
This became dead weight when looping_components_ partitioning was
introduced in June 2025 (8a06c4380d). Before that, Application::loop()
iterated components_[] which contained all states, so the state check
was necessary.
This commit is contained in:
@@ -173,7 +173,7 @@ void Application::loop() {
|
||||
{
|
||||
this->set_current_component(component);
|
||||
WarnIfComponentBlockingGuard guard{component, last_op_end_time};
|
||||
component->call();
|
||||
component->loop();
|
||||
// Use the finish method to get the current time as the end time
|
||||
last_op_end_time = guard.finish();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user