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:
@@ -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
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user