mirror of
https://github.com/esphome/esphome.git
synced 2026-09-26 06:20:21 +00:00
[core] Replace Application name/friendly_name std::string with StringRef (#14532)
Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com>
This commit is contained in:
co-authored by
Copilot
parent
07e51886f3
commit
74e4b69654
@@ -23,13 +23,13 @@ void EntityBase::set_name(const char *name, uint32_t object_id_hash) {
|
||||
// Bug-for-bug compatibility with OLD behavior:
|
||||
// - With MAC suffix: OLD code used App.get_friendly_name() directly (no fallback)
|
||||
// - Without MAC suffix: OLD code used pre-computed object_id with fallback to device name
|
||||
const std::string &friendly = App.get_friendly_name();
|
||||
const auto &friendly = App.get_friendly_name();
|
||||
if (App.is_name_add_mac_suffix_enabled()) {
|
||||
// MAC suffix enabled - use friendly_name directly (even if empty) for compatibility
|
||||
this->name_ = StringRef(friendly);
|
||||
this->name_ = friendly;
|
||||
} else {
|
||||
// No MAC suffix - fallback to device name if friendly_name is empty
|
||||
this->name_ = StringRef(!friendly.empty() ? friendly : App.get_name());
|
||||
this->name_ = !friendly.empty() ? friendly : App.get_name();
|
||||
}
|
||||
}
|
||||
this->flags_.has_own_name = false;
|
||||
|
||||
Reference in New Issue
Block a user