From dfc96496c8ca76f540497bc0b6c5dda2280dc1aa Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Sun, 15 Jun 2025 18:44:15 -0500 Subject: [PATCH] comments --- esphome/core/application.cpp | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/esphome/core/application.cpp b/esphome/core/application.cpp index e1432a1eba..a47bfdf484 100644 --- a/esphome/core/application.cpp +++ b/esphome/core/application.cpp @@ -261,8 +261,7 @@ void Application::disable_component_loop(Component *component) { // Move last active component to this position this->looping_components_active_end_--; if (i != this->looping_components_active_end_) { - this->looping_components_[i] = this->looping_components_[this->looping_components_active_end_]; - this->looping_components_[this->looping_components_active_end_] = component; + std::swap(this->looping_components_[i], this->looping_components_[this->looping_components_active_end_]); // If we're currently iterating and just swapped the current position if (this->in_loop_ && i == this->current_loop_index_) { @@ -287,9 +286,7 @@ void Application::enable_component_loop(Component *component) { } // Found in inactive section - move to active if (i != this->looping_components_active_end_) { - Component *temp = this->looping_components_[this->looping_components_active_end_]; - this->looping_components_[this->looping_components_active_end_] = component; - this->looping_components_[i] = temp; + std::swap(this->looping_components_[i], this->looping_components_[this->looping_components_active_end_]); } this->looping_components_active_end_++; return;