mirror of
https://github.com/esphome/esphome.git
synced 2026-09-16 01:28:39 +00:00
[text_sensor] Assert size before writing, not after
This commit is contained in:
@@ -165,11 +165,11 @@ bool map_filter_apply(const Substitution *mappings, size_t count, std::string &v
|
||||
template<size_t N> class MapFilter : public Filter {
|
||||
public:
|
||||
explicit MapFilter(const std::initializer_list<Substitution> &mappings) {
|
||||
ESPHOME_DEBUG_ASSERT(mappings.size() == N);
|
||||
size_t i = 0;
|
||||
for (const auto &m : mappings) {
|
||||
this->mappings_[i++] = m;
|
||||
}
|
||||
ESPHOME_DEBUG_ASSERT(i == N);
|
||||
}
|
||||
bool new_value(std::string &value) override { return map_filter_apply(this->mappings_.data(), N, value); }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user