[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-14 09:39:38 +13:00
committed by GitHub
co-authored by Copilot
parent 0f356fcc79
commit 8d8fcfeda2
9 changed files with 64 additions and 9 deletions
@@ -691,7 +691,9 @@ void EthernetComponent::set_manual_ip(const ManualIP &manual_ip) { this->manual_
std::string EthernetComponent::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_;
}