Replace std::move() with const references where possible (#2421)

* Replace std::move() with const references where possible

* Fix formatting
This commit is contained in:
Oxan van Leeuwen 2021-09-30 16:25:08 +02:00 committed by GitHub
parent 0e4f1ac40d
commit 5b0fbbaada
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 10 additions and 11 deletions

View File

@ -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();

View File

@ -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); };

View File

@ -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:

View File

@ -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); });
}
};

View File

@ -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); });
}
};

View File

@ -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); });
}
};

View File

@ -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:

View File

@ -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); });
}
};