mirror of
https://github.com/esphome/esphome.git
synced 2026-10-01 00:40:21 +00:00
[text_sensor] Avoid string copies in callbacks by passing const ref (#12503)
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: Jonathan Swoboda <154711427+swoboda1337@users.noreply.github.com>
This commit is contained in:
co-authored by
Copilot
Jonathan Swoboda
parent
121375ff39
commit
64269334ce
@@ -71,10 +71,10 @@ void TextSensor::clear_filters() {
|
||||
this->filter_list_ = nullptr;
|
||||
}
|
||||
|
||||
void TextSensor::add_on_state_callback(std::function<void(std::string)> callback) {
|
||||
void TextSensor::add_on_state_callback(std::function<void(const std::string &)> callback) {
|
||||
this->callback_.add(std::move(callback));
|
||||
}
|
||||
void TextSensor::add_on_raw_state_callback(std::function<void(std::string)> callback) {
|
||||
void TextSensor::add_on_raw_state_callback(std::function<void(const std::string &)> callback) {
|
||||
this->raw_callback_.add(std::move(callback));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user