From 93fdea954fe382b2a0add9166ce6e252c4b10c82 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Tue, 22 Jul 2025 07:46:21 -1000 Subject: [PATCH] [api] Use emplace_back for TemplatableKeyValuePair construction in HomeAssistant services --- esphome/components/api/homeassistant_service.h | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/esphome/components/api/homeassistant_service.h b/esphome/components/api/homeassistant_service.h index 4980c0224c..6df29f2963 100644 --- a/esphome/components/api/homeassistant_service.h +++ b/esphome/components/api/homeassistant_service.h @@ -47,15 +47,11 @@ template class HomeAssistantServiceCallAction : public Action void set_service(T service) { this->service_ = service; } - template void add_data(std::string key, T value) { - this->data_.push_back(TemplatableKeyValuePair(key, value)); - } + template void add_data(std::string key, T value) { this->data_.emplace_back(key, value); } template void add_data_template(std::string key, T value) { - this->data_template_.push_back(TemplatableKeyValuePair(key, value)); - } - template void add_variable(std::string key, T value) { - this->variables_.push_back(TemplatableKeyValuePair(key, value)); + this->data_template_.emplace_back(key, value); } + template void add_variable(std::string key, T value) { this->variables_.emplace_back(key, value); } void play(Ts... x) override { HomeassistantServiceResponse resp;