replaced std::string with a simple pointer to the string literal in main.cpp

This commit is contained in:
Gábor Poczkodi 2024-11-08 16:58:42 +01:00
parent 889b2f24bb
commit 0ec353c112
2 changed files with 7 additions and 5 deletions

View file

@ -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')

View file

@ -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;
};