mirror of
https://github.com/esphome/esphome.git
synced 2025-07-28 22:26:36 +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()) {
|
if (!this->queue_.empty()) {
|
||||||
// Copy queue without NaN values
|
// Copy queue without NaN values
|
||||||
std::vector<float> median_queue;
|
std::vector<float> median_queue;
|
||||||
|
median_queue.reserve(this->queue_.size());
|
||||||
for (auto v : this->queue_) {
|
for (auto v : this->queue_) {
|
||||||
if (!std::isnan(v)) {
|
if (!std::isnan(v)) {
|
||||||
median_queue.push_back(v);
|
median_queue.push_back(v);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user