mirror of
				https://github.com/esphome/esphome.git
				synced 2025-11-04 00:51:49 +00: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:
		@@ -40,7 +40,7 @@ class HttpRequestComponent : public Component {
 | 
				
			|||||||
  void set_method(const char *method) { this->method_ = method; }
 | 
					  void set_method(const char *method) { this->method_ = method; }
 | 
				
			||||||
  void set_useragent(const char *useragent) { this->useragent_ = useragent; }
 | 
					  void set_useragent(const char *useragent) { this->useragent_ = useragent; }
 | 
				
			||||||
  void set_timeout(uint16_t timeout) { this->timeout_ = timeout; }
 | 
					  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 set_headers(std::list<Header> headers) { this->headers_ = std::move(headers); }
 | 
				
			||||||
  void send(const std::vector<HttpRequestResponseTrigger *> &response_triggers);
 | 
					  void send(const std::vector<HttpRequestResponseTrigger *> &response_triggers);
 | 
				
			||||||
  void close();
 | 
					  void close();
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -13,7 +13,7 @@ class PipsolarOutput : public output::FloatOutput {
 | 
				
			|||||||
 public:
 | 
					 public:
 | 
				
			||||||
  PipsolarOutput() {}
 | 
					  PipsolarOutput() {}
 | 
				
			||||||
  void set_parent(Pipsolar *parent) { this->parent_ = parent; }
 | 
					  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_possible_values(std::vector<float> possible_values) { this->possible_values_ = std::move(possible_values); }
 | 
				
			||||||
  void set_value(float value) { this->write_state(value); };
 | 
					  void set_value(float value) { this->write_state(value); };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -10,8 +10,8 @@ class Pipsolar;
 | 
				
			|||||||
class PipsolarSwitch : public switch_::Switch, public Component {
 | 
					class PipsolarSwitch : public switch_::Switch, public Component {
 | 
				
			||||||
 public:
 | 
					 public:
 | 
				
			||||||
  void set_parent(Pipsolar *parent) { this->parent_ = parent; };
 | 
					  void set_parent(Pipsolar *parent) { this->parent_ = parent; };
 | 
				
			||||||
  void set_on_command(std::string command) { this->on_command_ = std::move(command); };
 | 
					  void set_on_command(const std::string &command) { this->on_command_ = command; };
 | 
				
			||||||
  void set_off_command(std::string command) { this->off_command_ = std::move(command); };
 | 
					  void set_off_command(const std::string &command) { this->off_command_ = command; };
 | 
				
			||||||
  void dump_config() override;
 | 
					  void dump_config() override;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 protected:
 | 
					 protected:
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -85,8 +85,7 @@ class RFBridgeReceivedCodeTrigger : public Trigger<RFBridgeData> {
 | 
				
			|||||||
class RFBridgeReceivedAdvancedCodeTrigger : public Trigger<RFBridgeAdvancedData> {
 | 
					class RFBridgeReceivedAdvancedCodeTrigger : public Trigger<RFBridgeAdvancedData> {
 | 
				
			||||||
 public:
 | 
					 public:
 | 
				
			||||||
  explicit RFBridgeReceivedAdvancedCodeTrigger(RFBridgeComponent *parent) {
 | 
					  explicit RFBridgeReceivedAdvancedCodeTrigger(RFBridgeComponent *parent) {
 | 
				
			||||||
    parent->add_on_advanced_code_received_callback(
 | 
					    parent->add_on_advanced_code_received_callback([this](const RFBridgeAdvancedData &data) { this->trigger(data); });
 | 
				
			||||||
        [this](RFBridgeAdvancedData data) { this->trigger(std::move(data)); });
 | 
					 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -10,7 +10,7 @@ namespace select {
 | 
				
			|||||||
class SelectStateTrigger : public Trigger<std::string> {
 | 
					class SelectStateTrigger : public Trigger<std::string> {
 | 
				
			||||||
 public:
 | 
					 public:
 | 
				
			||||||
  explicit SelectStateTrigger(Select *parent) {
 | 
					  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:
 | 
					 public:
 | 
				
			||||||
  explicit Sim800LReceivedMessageTrigger(Sim800LComponent *parent) {
 | 
					  explicit Sim800LReceivedMessageTrigger(Sim800LComponent *parent) {
 | 
				
			||||||
    parent->add_on_sms_received_callback(
 | 
					    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_; }
 | 
					  Trigger<std::string> *get_set_trigger() const { return this->set_trigger_; }
 | 
				
			||||||
  void set_optimistic(bool optimistic) { this->optimistic_ = optimistic; }
 | 
					  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; }
 | 
					  void set_restore_value(bool restore_value) { this->restore_value_ = restore_value; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 protected:
 | 
					 protected:
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -12,14 +12,14 @@ namespace text_sensor {
 | 
				
			|||||||
class TextSensorStateTrigger : public Trigger<std::string> {
 | 
					class TextSensorStateTrigger : public Trigger<std::string> {
 | 
				
			||||||
 public:
 | 
					 public:
 | 
				
			||||||
  explicit TextSensorStateTrigger(TextSensor *parent) {
 | 
					  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> {
 | 
					class TextSensorStateRawTrigger : public Trigger<std::string> {
 | 
				
			||||||
 public:
 | 
					 public:
 | 
				
			||||||
  explicit TextSensorStateRawTrigger(TextSensor *parent) {
 | 
					  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); });
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user