1
0
mirror of https://github.com/esphome/esphome.git synced 2025-11-18 15:55:46 +00:00

[core] Add make_name_with_suffix helper to optimize string concatenation (#11176)

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
J. Nick Koston
2025-10-13 10:39:38 -10:00
committed by GitHub
parent 0f356fcc79
commit 8d8fcfeda2
9 changed files with 64 additions and 9 deletions

View File

@@ -267,7 +267,9 @@ network::IPAddress WiFiComponent::get_dns_address(int num) {
}
std::string WiFiComponent::get_use_address() const {
if (this->use_address_.empty()) {
return App.get_name() + ".local";
// ".local" suffix length for mDNS hostnames
constexpr size_t mdns_local_suffix_len = 5;
return make_name_with_suffix(App.get_name(), '.', "local", mdns_local_suffix_len);
}
return this->use_address_;
}