avoid some conversion overhead

This commit is contained in:
J. Nick Koston
2026-02-11 13:51:49 -06:00
parent 2506831445
commit 18a6e43db8
2 changed files with 5 additions and 5 deletions

View File

@@ -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

View File

@@ -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 {