1
0
mirror of https://github.com/esphome/esphome.git synced 2025-06-15 23:06:58 +02:00

Optimize Application area_ from std::string to const char* (#9085)

This commit is contained in:
J. Nick Koston 2025-06-14 22:46:40 -05:00 committed by GitHub
parent 98e2684107
commit 78e3c6333f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 5 additions and 5 deletions

View File

@ -153,7 +153,7 @@ bool MQTTComponent::send_discovery_() {
if (node_friendly_name.empty()) {
node_friendly_name = node_name;
}
const std::string &node_area = App.get_area();
std::string node_area = App.get_area();
JsonObject device_info = root.createNestedObject(MQTT_DEVICE);
const auto mac = get_mac_address();

View File

@ -87,8 +87,8 @@ static const uint32_t TEARDOWN_TIMEOUT_REBOOT_MS = 1000; // 1 second for quick
class Application {
public:
void pre_setup(const std::string &name, const std::string &friendly_name, const std::string &area,
const char *comment, const char *compilation_time, bool name_add_mac_suffix) {
void pre_setup(const std::string &name, const std::string &friendly_name, const char *area, const char *comment,
const char *compilation_time, bool name_add_mac_suffix) {
arch_init();
this->name_add_mac_suffix_ = name_add_mac_suffix;
if (name_add_mac_suffix) {
@ -285,7 +285,7 @@ class Application {
const std::string &get_friendly_name() const { return this->friendly_name_; }
/// Get the area of this Application set by pre_setup().
const std::string &get_area() const { return this->area_; }
std::string get_area() const { return this->area_ == nullptr ? "" : this->area_; }
/// Get the comment of this Application set by pre_setup().
std::string get_comment() const { return this->comment_; }
@ -646,7 +646,7 @@ class Application {
std::string name_;
std::string friendly_name_;
std::string area_;
const char *area_{nullptr};
const char *comment_{nullptr};
const char *compilation_time_{nullptr};
bool name_add_mac_suffix_;