mirror of
https://github.com/esphome/esphome.git
synced 2025-07-29 14:46:40 +00:00
Optimize Application area_ from std::string to const char* (#9085)
This commit is contained in:
parent
1719a2e08b
commit
5cdcf2415d
@ -153,7 +153,7 @@ bool MQTTComponent::send_discovery_() {
|
|||||||
if (node_friendly_name.empty()) {
|
if (node_friendly_name.empty()) {
|
||||||
node_friendly_name = node_name;
|
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);
|
JsonObject device_info = root.createNestedObject(MQTT_DEVICE);
|
||||||
const auto mac = get_mac_address();
|
const auto mac = get_mac_address();
|
||||||
|
@ -87,8 +87,8 @@ static const uint32_t TEARDOWN_TIMEOUT_REBOOT_MS = 1000; // 1 second for quick
|
|||||||
|
|
||||||
class Application {
|
class Application {
|
||||||
public:
|
public:
|
||||||
void pre_setup(const std::string &name, const std::string &friendly_name, const std::string &area,
|
void pre_setup(const std::string &name, const std::string &friendly_name, const char *area, const char *comment,
|
||||||
const char *comment, const char *compilation_time, bool name_add_mac_suffix) {
|
const char *compilation_time, bool name_add_mac_suffix) {
|
||||||
arch_init();
|
arch_init();
|
||||||
this->name_add_mac_suffix_ = name_add_mac_suffix;
|
this->name_add_mac_suffix_ = name_add_mac_suffix;
|
||||||
if (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_; }
|
const std::string &get_friendly_name() const { return this->friendly_name_; }
|
||||||
|
|
||||||
/// Get the area of this Application set by pre_setup().
|
/// 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().
|
/// Get the comment of this Application set by pre_setup().
|
||||||
std::string get_comment() const { return this->comment_; }
|
std::string get_comment() const { return this->comment_; }
|
||||||
@ -646,7 +646,7 @@ class Application {
|
|||||||
|
|
||||||
std::string name_;
|
std::string name_;
|
||||||
std::string friendly_name_;
|
std::string friendly_name_;
|
||||||
std::string area_;
|
const char *area_{nullptr};
|
||||||
const char *comment_{nullptr};
|
const char *comment_{nullptr};
|
||||||
const char *compilation_time_{nullptr};
|
const char *compilation_time_{nullptr};
|
||||||
bool name_add_mac_suffix_;
|
bool name_add_mac_suffix_;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user