1
0
mirror of https://github.com/esphome/esphome.git synced 2025-09-06 21:32:21 +01:00

[core] Optimize Application::pre_setup() to reduce duplicate MAC address operations

This commit is contained in:
J. Nick Koston
2025-08-02 15:56:47 -10:00
parent 296442d8f1
commit 7a8b2feec6

View File

@@ -101,12 +101,9 @@ class Application {
arch_init();
this->name_add_mac_suffix_ = name_add_mac_suffix;
if (name_add_mac_suffix) {
this->name_ = name + "-" + get_mac_address().substr(6);
if (friendly_name.empty()) {
this->friendly_name_ = "";
} else {
this->friendly_name_ = friendly_name + " " + get_mac_address().substr(6);
}
const std::string mac_suffix = get_mac_address().substr(6);
this->name_ = name + "-" + mac_suffix;
this->friendly_name_ = friendly_name.empty() ? "" : friendly_name + " " + mac_suffix;
} else {
this->name_ = name;
this->friendly_name_ = friendly_name;