Inline is_connected_ and update_connected_state_ into header

Move these small methods to the header so the compiler can inline
them into loop(), eliminating two function call/return pairs from
every loop iteration on all platforms.
This commit is contained in:
J. Nick Koston
2026-03-29 18:29:03 -10:00
parent d52d5bbda3
commit 96a23e5d3d
2 changed files with 5 additions and 7 deletions
@@ -2130,11 +2130,6 @@ void WiFiComponent::retry_connect() {
}
void WiFiComponent::set_reboot_timeout(uint32_t reboot_timeout) { this->reboot_timeout_ = reboot_timeout; }
bool WiFiComponent::is_connected_() const {
return this->state_ == WIFI_COMPONENT_STATE_STA_CONNECTED &&
this->wifi_sta_connect_status_() == WiFiSTAConnectStatus::CONNECTED && !this->error_from_callback_;
}
void WiFiComponent::update_connected_state_() { this->connected_ = this->is_connected_(); }
void WiFiComponent::set_power_save_mode(WiFiPowerSaveMode power_save) {
this->power_save_ = power_save;
#if defined(USE_ESP32) && defined(USE_WIFI_RUNTIME_POWER_SAVE)
+5 -2
View File
@@ -681,8 +681,11 @@ class WiFiComponent final : public Component {
bool wifi_sta_connect_(const WiFiAP &ap);
void wifi_pre_setup_();
WiFiSTAConnectStatus wifi_sta_connect_status_() const;
bool is_connected_() const;
void update_connected_state_();
bool is_connected_() const {
return this->state_ == WIFI_COMPONENT_STATE_STA_CONNECTED &&
this->wifi_sta_connect_status_() == WiFiSTAConnectStatus::CONNECTED && !this->error_from_callback_;
}
void update_connected_state_() { this->connected_ = this->is_connected_(); }
bool wifi_scan_start_(bool passive);
#ifdef USE_WIFI_AP