From 8fd7c006130e832e5ac0cc71c611a5c05840b987 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Sat, 6 Dec 2025 22:29:24 -0600 Subject: [PATCH] [text_sensor] Use StringRef for filter static data to avoid heap allocation --- esphome/components/text_sensor/filter.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/esphome/components/text_sensor/filter.cpp b/esphome/components/text_sensor/filter.cpp index a6d0ae0c93..52c2bd394e 100644 --- a/esphome/components/text_sensor/filter.cpp +++ b/esphome/components/text_sensor/filter.cpp @@ -62,7 +62,10 @@ optional AppendFilter::new_value(std::string value) { } // Prepend -optional PrependFilter::new_value(std::string value) { return this->prefix_ + value; } +optional PrependFilter::new_value(std::string value) { + value.insert(0, this->prefix_.c_str(), this->prefix_.size()); + return value; +} // Substitute SubstituteFilter::SubstituteFilter(const std::initializer_list &substitutions)