[code-quality] fix performance-unnecessary-value-param

This commit is contained in:
Tomasz Duda 2024-08-14 00:15:07 +02:00
parent bc3221a55b
commit 61db16bf2d
4 changed files with 12 additions and 4 deletions

View file

@ -1,5 +1,7 @@
#pragma once
#include <utility>
#include "esphome/components/number/number.h"
#include "esphome/core/automation.h"
#include "esphome/core/component.h"
@ -11,7 +13,7 @@ namespace lvgl {
class LVGLNumber : public number::Number {
public:
void set_control_lambda(std::function<void(float)> control_lambda) {
this->control_lambda_ = control_lambda;
this->control_lambda_ = std::move(control_lambda);
if (this->initial_state_.has_value()) {
this->control_lambda_(this->initial_state_.value());
this->initial_state_.reset();

View file

@ -1,5 +1,7 @@
#pragma once
#include <utility>
#include "esphome/components/select/select.h"
#include "esphome/core/automation.h"
#include "esphome/core/component.h"
@ -28,7 +30,7 @@ static std::vector<std::string> split_string(const std::string &str) {
class LVGLSelect : public select::Select {
public:
void set_control_lambda(std::function<void(size_t)> lambda) {
this->control_lambda_ = lambda;
this->control_lambda_ = std::move(lambda);
if (this->initial_state_.has_value()) {
this->control(this->initial_state_.value());
this->initial_state_.reset();

View file

@ -1,5 +1,7 @@
#pragma once
#include <utility>
#include "esphome/components/switch/switch.h"
#include "esphome/core/automation.h"
#include "esphome/core/component.h"
@ -11,7 +13,7 @@ namespace lvgl {
class LVGLSwitch : public switch_::Switch {
public:
void set_control_lambda(std::function<void(bool)> state_lambda) {
this->state_lambda_ = state_lambda;
this->state_lambda_ = std::move(state_lambda);
if (this->initial_state_.has_value()) {
this->state_lambda_(this->initial_state_.value());
this->initial_state_.reset();

View file

@ -1,5 +1,7 @@
#pragma once
#include <utility>
#include "esphome/components/text/text.h"
#include "esphome/core/automation.h"
#include "esphome/core/component.h"
@ -11,7 +13,7 @@ namespace lvgl {
class LVGLText : public text::Text {
public:
void set_control_lambda(std::function<void(const std::string)> control_lambda) {
this->control_lambda_ = control_lambda;
this->control_lambda_ = std::move(control_lambda);
if (this->initial_state_.has_value()) {
this->control_lambda_(this->initial_state_.value());
this->initial_state_.reset();