mirror of
https://github.com/esphome/esphome.git
synced 2025-07-28 14:16:40 +00:00
Optimize MedianFilter memory allocation by adding vector reserve (#9531)
This commit is contained in:
parent
f745135bdc
commit
ab54a880c1
@ -50,6 +50,7 @@ optional<float> MedianFilter::new_value(float value) {
|
||||
if (!this->queue_.empty()) {
|
||||
// Copy queue without NaN values
|
||||
std::vector<float> median_queue;
|
||||
median_queue.reserve(this->queue_.size());
|
||||
for (auto v : this->queue_) {
|
||||
if (!std::isnan(v)) {
|
||||
median_queue.push_back(v);
|
||||
|
Loading…
x
Reference in New Issue
Block a user