mirror of
https://github.com/esphome/esphome.git
synced 2024-12-22 13:34:54 +01:00
Replace std::move() with const references where possible (#2421)
* Replace std::move() with const references where possible * Fix formatting
This commit is contained in:
parent
0e4f1ac40d
commit
5b0fbbaada
8 changed files with 10 additions and 11 deletions
|
@ -40,7 +40,7 @@ class HttpRequestComponent : public Component {
|
|||
void set_method(const char *method) { this->method_ = method; }
|
||||
void set_useragent(const char *useragent) { this->useragent_ = useragent; }
|
||||
void set_timeout(uint16_t timeout) { this->timeout_ = timeout; }
|
||||
void set_body(std::string body) { this->body_ = std::move(body); }
|
||||
void set_body(const std::string &body) { this->body_ = body; }
|
||||
void set_headers(std::list<Header> headers) { this->headers_ = std::move(headers); }
|
||||
void send(const std::vector<HttpRequestResponseTrigger *> &response_triggers);
|
||||
void close();
|
||||
|
|
|
@ -13,7 +13,7 @@ class PipsolarOutput : public output::FloatOutput {
|
|||
public:
|
||||
PipsolarOutput() {}
|
||||
void set_parent(Pipsolar *parent) { this->parent_ = parent; }
|
||||
void set_set_command(std::string command) { this->set_command_ = std::move(command); };
|
||||
void set_set_command(const std::string &command) { this->set_command_ = command; };
|
||||
void set_possible_values(std::vector<float> possible_values) { this->possible_values_ = std::move(possible_values); }
|
||||
void set_value(float value) { this->write_state(value); };
|
||||
|
||||
|
|
|
@ -10,8 +10,8 @@ class Pipsolar;
|
|||
class PipsolarSwitch : public switch_::Switch, public Component {
|
||||
public:
|
||||
void set_parent(Pipsolar *parent) { this->parent_ = parent; };
|
||||
void set_on_command(std::string command) { this->on_command_ = std::move(command); };
|
||||
void set_off_command(std::string command) { this->off_command_ = std::move(command); };
|
||||
void set_on_command(const std::string &command) { this->on_command_ = command; };
|
||||
void set_off_command(const std::string &command) { this->off_command_ = command; };
|
||||
void dump_config() override;
|
||||
|
||||
protected:
|
||||
|
|
|
@ -85,8 +85,7 @@ class RFBridgeReceivedCodeTrigger : public Trigger<RFBridgeData> {
|
|||
class RFBridgeReceivedAdvancedCodeTrigger : public Trigger<RFBridgeAdvancedData> {
|
||||
public:
|
||||
explicit RFBridgeReceivedAdvancedCodeTrigger(RFBridgeComponent *parent) {
|
||||
parent->add_on_advanced_code_received_callback(
|
||||
[this](RFBridgeAdvancedData data) { this->trigger(std::move(data)); });
|
||||
parent->add_on_advanced_code_received_callback([this](const RFBridgeAdvancedData &data) { this->trigger(data); });
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ namespace select {
|
|||
class SelectStateTrigger : public Trigger<std::string> {
|
||||
public:
|
||||
explicit SelectStateTrigger(Select *parent) {
|
||||
parent->add_on_state_callback([this](std::string value) { this->trigger(std::move(value)); });
|
||||
parent->add_on_state_callback([this](const std::string &value) { this->trigger(value); });
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -74,7 +74,7 @@ class Sim800LReceivedMessageTrigger : public Trigger<std::string, std::string> {
|
|||
public:
|
||||
explicit Sim800LReceivedMessageTrigger(Sim800LComponent *parent) {
|
||||
parent->add_on_sms_received_callback(
|
||||
[this](std::string message, std::string sender) { this->trigger(std::move(message), std::move(sender)); });
|
||||
[this](const std::string &message, const std::string &sender) { this->trigger(message, sender); });
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ class TemplateSelect : public select::Select, public PollingComponent {
|
|||
|
||||
Trigger<std::string> *get_set_trigger() const { return this->set_trigger_; }
|
||||
void set_optimistic(bool optimistic) { this->optimistic_ = optimistic; }
|
||||
void set_initial_option(std::string initial_option) { this->initial_option_ = std::move(initial_option); }
|
||||
void set_initial_option(const std::string &initial_option) { this->initial_option_ = initial_option; }
|
||||
void set_restore_value(bool restore_value) { this->restore_value_ = restore_value; }
|
||||
|
||||
protected:
|
||||
|
|
|
@ -12,14 +12,14 @@ namespace text_sensor {
|
|||
class TextSensorStateTrigger : public Trigger<std::string> {
|
||||
public:
|
||||
explicit TextSensorStateTrigger(TextSensor *parent) {
|
||||
parent->add_on_state_callback([this](std::string value) { this->trigger(std::move(value)); });
|
||||
parent->add_on_state_callback([this](const std::string &value) { this->trigger(value); });
|
||||
}
|
||||
};
|
||||
|
||||
class TextSensorStateRawTrigger : public Trigger<std::string> {
|
||||
public:
|
||||
explicit TextSensorStateRawTrigger(TextSensor *parent) {
|
||||
parent->add_on_raw_state_callback([this](std::string value) { this->trigger(std::move(value)); });
|
||||
parent->add_on_raw_state_callback([this](const std::string &value) { this->trigger(value); });
|
||||
}
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue