From 18a6e43db86b62b7df5f760f9f0f27f7bb787671 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Wed, 11 Feb 2026 13:51:49 -0600 Subject: [PATCH] avoid some conversion overhead --- esphome/components/wifi/wifi_component.cpp | 4 ++-- esphome/components/wifi/wifi_component.h | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/esphome/components/wifi/wifi_component.cpp b/esphome/components/wifi/wifi_component.cpp index 6fe97c69a1..d1014de43c 100644 --- a/esphome/components/wifi/wifi_component.cpp +++ b/esphome/components/wifi/wifi_component.cpp @@ -2203,7 +2203,7 @@ bool WiFiScanResult::matches(const WiFiAP &config) const { return false; } else if (!config.get_ssid().empty()) { // check if SSID matches - if (config.get_ssid() != this->ssid_.ref()) + if (this->ssid_ != config.get_ssid()) return false; } else { // network is configured without SSID - match other settings @@ -2345,7 +2345,7 @@ void WiFiComponent::process_roaming_scan_() { for (const auto &result : this->scan_result_) { // Must be same SSID, different BSSID - if (result.get_ssid() != current_ssid.c_str() || result.get_bssid() == current_bssid) + if (result.get_ssid() != current_ssid || result.get_bssid() == current_bssid) continue; #if ESPHOME_LOG_LEVEL >= ESPHOME_LOG_LEVEL_VERBOSE diff --git a/esphome/components/wifi/wifi_component.h b/esphome/components/wifi/wifi_component.h index 8962151590..cc97381e39 100644 --- a/esphome/components/wifi/wifi_component.h +++ b/esphome/components/wifi/wifi_component.h @@ -196,10 +196,10 @@ class CompactString { /// Return a StringRef view of this string (zero-copy) StringRef ref() const { return StringRef(this->data(), this->size()); } - bool operator==(const CompactString &other) const { - return this->size() == other.size() && std::memcmp(this->data(), other.data(), this->size()) == 0; + bool operator==(const StringRef &other) const { + return this->size() == other.size() && std::memcmp(this->data(), other.c_str(), this->size()) == 0; } - bool operator!=(const CompactString &other) const { return !(*this == other); } + bool operator!=(const StringRef &other) const { return !(*this == other); } protected: char *get_heap_ptr_() const {