[code-quality] fix performance-unnecessary-value-param (#7274)

This commit is contained in:
tomaszduda23 2024-08-14 23:05:16 +02:00 committed by GitHub
parent fef592b6c6
commit 80a0f13722
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
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();