1
0
mirror of https://github.com/esphome/esphome.git synced 2026-02-08 00:31:58 +00:00

[scheduler] Replace resize() with erase() to save ~ 436 bytes flash (#13214)

This commit is contained in:
J. Nick Koston
2026-01-18 18:54:30 -10:00
committed by GitHub
parent e80a940222
commit d8a28f6fba

View File

@@ -403,7 +403,9 @@ class Scheduler {
for (size_t i = 0; i < remaining; i++) {
this->defer_queue_[i] = std::move(this->defer_queue_[this->defer_queue_front_ + i]);
}
this->defer_queue_.resize(remaining);
// Use erase() instead of resize() to avoid instantiating _M_default_append
// (saves ~156 bytes flash). Erasing from the end is O(1) - no shifting needed.
this->defer_queue_.erase(this->defer_queue_.begin() + remaining, this->defer_queue_.end());
}
this->defer_queue_front_ = 0;
}