mirror of
				https://github.com/esphome/esphome.git
				synced 2025-10-31 15:12:06 +00:00 
			
		
		
		
	Optimize MedianFilter memory allocation by adding vector reserve (#9531)
This commit is contained in:
		| @@ -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); | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user