mirror of
https://github.com/esphome/esphome.git
synced 2024-11-27 17:27:59 +01:00
pass string as const reference instead of copying
This commit is contained in:
parent
c77935b3ec
commit
f08c1d56da
4 changed files with 5 additions and 9 deletions
|
@ -63,14 +63,10 @@ bool ListEntitiesIterator::on_button(button::Button *button) {
|
|||
#endif
|
||||
#ifdef USE_TEXT_SENSOR
|
||||
bool ListEntitiesIterator::on_text_sensor(text_sensor::TextSensor *text_sensor) {
|
||||
<<<<<<< HEAD
|
||||
if (!this->has_connected_client())
|
||||
return true;
|
||||
return this->process(
|
||||
this->web_server_->text_sensor_json(text_sensor, text_sensor->state, DETAIL_ALL));
|
||||
=======
|
||||
return this->process(this->web_server_->text_sensor_json(text_sensor, text_sensor->state, DETAIL_ALL));
|
||||
>>>>>>> 4d9a3ae3c (make lint checker happier)
|
||||
}
|
||||
#endif
|
||||
#ifdef USE_LOCK
|
||||
|
@ -174,7 +170,7 @@ bool ListEntitiesIterator::on_update(update::UpdateEntity *update) {
|
|||
|
||||
bool ListEntitiesIterator::has_connected_client() { return this->web_server_->events_.count() > 0; }
|
||||
|
||||
bool ListEntitiesIterator::process(std::string s) {
|
||||
bool ListEntitiesIterator::process(const std::string &s) {
|
||||
this->web_server_->events_.send(s.c_str(), "state");
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -75,8 +75,8 @@ class ListEntitiesIterator : public ComponentIterator {
|
|||
|
||||
protected:
|
||||
WebServer *web_server_;
|
||||
bool has_connected_client();
|
||||
virtual bool process(std::string s);
|
||||
virtual bool has_connected_client();
|
||||
virtual bool process(const std::string &s);
|
||||
};
|
||||
|
||||
} // namespace web_server
|
||||
|
|
|
@ -12,7 +12,7 @@ StatesIterator::StatesIterator(WebServer *web_server) : ListEntitiesIterator::Li
|
|||
|
||||
bool StatesIterator::has_connected_client() { return true; }
|
||||
|
||||
bool StatesIterator::process(std::string s) {
|
||||
bool StatesIterator::process(const std::string &s) {
|
||||
this->str_ = s;
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@ class StatesIterator : public ListEntitiesIterator {
|
|||
protected:
|
||||
// WebServer *web_server_;
|
||||
optional<std::string> str_;
|
||||
bool process(std::string s) override;
|
||||
bool process(const std::string &s) override;
|
||||
};
|
||||
|
||||
} // namespace web_server
|
||||
|
|
Loading…
Reference in a new issue