From b80b0eb864281158112990eac22800bb0fe0a0d4 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Mon, 10 Nov 2025 20:17:03 -0600 Subject: [PATCH] save more --- esphome/components/wifi/wifi_component.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/esphome/components/wifi/wifi_component.cpp b/esphome/components/wifi/wifi_component.cpp index 8c9deee552..629d8c1238 100644 --- a/esphome/components/wifi/wifi_component.cpp +++ b/esphome/components/wifi/wifi_component.cpp @@ -1293,7 +1293,7 @@ bool WiFiComponent::transition_to_phase_(WiFiRetryPhase new_phase) { return false; // Did not start scan, can proceed with connection } -/// Reset all BSSID priorities to 0 if they're all identical (can't differentiate) +/// Reset all BSSID priorities if they're all identical (can't differentiate) /// Called when starting a fresh connection attempt or after successful connection void WiFiComponent::reset_priorities_if_all_same_() { if (this->sta_priorities_.empty()) { @@ -1307,11 +1307,10 @@ void WiFiComponent::reset_priorities_if_all_same_() { } } - // All priorities are identical, reset to 0 - ESP_LOGD(TAG, "Resetting all BSSID priorities (all identical)"); - for (auto &pri : this->sta_priorities_) { - pri.priority = 0; - } + // All priorities are identical - clear the vector to save memory + ESP_LOGD(TAG, "Clearing BSSID priorities (all identical)"); + this->sta_priorities_.clear(); + this->sta_priorities_.shrink_to_fit(); } /// Log failed connection attempt and decrease BSSID priority to avoid repeated failures