From 0ec353c112324359f973ca75d5f4771fcb79f3e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A1bor=20Poczkodi?= Date: Fri, 8 Nov 2024 16:58:42 +0100 Subject: [PATCH] replaced std::string with a simple pointer to the string literal in main.cpp --- esphome/components/store_yaml/store_yaml.cpp | 4 ++-- esphome/components/store_yaml/store_yaml.h | 8 +++++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/esphome/components/store_yaml/store_yaml.cpp b/esphome/components/store_yaml/store_yaml.cpp index d7d8020ccc..e6e7124ea8 100644 --- a/esphome/components/store_yaml/store_yaml.cpp +++ b/esphome/components/store_yaml/store_yaml.cpp @@ -13,10 +13,10 @@ void StoreYamlComponent::dump_config() { } } -std::string StoreYamlComponent::get_yaml() const { return this->yaml_; } +const char *StoreYamlComponent::get_yaml() const { return this->yaml_; } void StoreYamlComponent::log(bool dump_config) const { - const char *s = this->yaml_.c_str(); + const char *s = this->yaml_; while (*s) { const char *e = s; while (*e && *e++ != '\n') diff --git a/esphome/components/store_yaml/store_yaml.h b/esphome/components/store_yaml/store_yaml.h index 989095805b..f58d3d1d02 100644 --- a/esphome/components/store_yaml/store_yaml.h +++ b/esphome/components/store_yaml/store_yaml.h @@ -3,17 +3,19 @@ #include "esphome/core/component.h" #include "esphome/core/automation.h" +extern const char ESPHOME_YAML[]; + namespace esphome { namespace store_yaml { class StoreYamlComponent : public Component { bool show_in_dump_config_{false}; - std::string yaml_; + const char *yaml_; public: void dump_config() override; void set_show_in_dump_config(bool show) { this->show_in_dump_config_ = show; } - void set_yaml(const std::string &yaml) { this->yaml_ = yaml; } - std::string get_yaml() const; + void set_yaml(const char *yaml) { this->yaml_ = yaml; } + const char *get_yaml() const; void log(bool dump_config = false) const; };