From 2d15a3c0e8baa30c29d8d4ef5127285fd970b6aa Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Tue, 22 Jul 2025 09:56:30 -1000 Subject: [PATCH] address clang-tidy --- esphome/components/api/homeassistant_service.h | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/esphome/components/api/homeassistant_service.h b/esphome/components/api/homeassistant_service.h index b164a1b87a..330dc5b1a1 100644 --- a/esphome/components/api/homeassistant_service.h +++ b/esphome/components/api/homeassistant_service.h @@ -5,6 +5,7 @@ #include "api_pb2.h" #include "esphome/core/automation.h" #include "esphome/core/helpers.h" +#include #include namespace esphome { @@ -36,10 +37,10 @@ template class TemplatableStringValue : public TemplatableValue class TemplatableKeyValuePair { public: - // It's safe to use const std::string& for the key parameter because keys are always - // string literals from YAML dictionary keys (e.g., "code", "event") and never - // templatable values or lambdas. Only the value parameter can be a lambda/template. - template TemplatableKeyValuePair(const std::string &key, T value) : key(key), value(value) {} + // Keys are always string literals from YAML dictionary keys (e.g., "code", "event") + // and never templatable values or lambdas. Only the value parameter can be a lambda/template. + // Using pass-by-value with std::move allows optimal performance for both lvalues and rvalues. + template TemplatableKeyValuePair(std::string key, T value) : key(std::move(key)), value(value) {} std::string key; TemplatableStringValue value; };