1
0
mirror of https://github.com/esphome/esphome.git synced 2026-02-08 08:41:59 +00:00

[wifi] Add CompactString to reduce WiFi scan heap fragmentation

This commit is contained in:
J. Nick Koston
2026-01-22 17:18:13 -10:00
parent 0ae90512cf
commit fca867e18d
2 changed files with 4 additions and 1 deletions

View File

@@ -267,7 +267,7 @@ bool ImprovSerialComponent::parse_improv_payload_(improv::ImprovCommand &command
for (auto &scan : results) {
if (scan.get_is_hidden())
continue;
std::string ssid = scan.get_ssid().c_str();
std::string ssid = scan.get_ssid();
if (std::find(networks.begin(), networks.end(), ssid) != networks.end())
continue;
// Send each ssid separately to avoid overflowing the buffer

View File

@@ -1769,6 +1769,9 @@ class CompactString {
size_t size() const { return this->length_; }
bool empty() const { return this->length_ == 0; }
// Implicit conversion to std::string for backwards compatibility
operator std::string() const { return std::string(this->data(), this->size()); }
bool operator==(const CompactString &other) const {
return this->size() == other.size() && std::memcmp(this->data(), other.data(), this->size()) == 0;
}