[text_sensor] Use StringRef for filter static data to avoid heap allocation

This commit is contained in:
J. Nick Koston
2025-12-06 22:29:24 -06:00
parent 49e7ccd937
commit 8fd7c00613

View File

@@ -62,7 +62,10 @@ optional<std::string> AppendFilter::new_value(std::string value) {
}
// Prepend
optional<std::string> PrependFilter::new_value(std::string value) { return this->prefix_ + value; }
optional<std::string> 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<Substitution> &substitutions)