Optimize MedianFilter memory allocation by adding vector reserve (#9531)

This commit is contained in:
J. Nick Koston 2025-07-15 15:25:41 -10:00 committed by GitHub
parent f745135bdc
commit ab54a880c1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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);