[core] Devirtualize PollingComponent::set_update_interval

Remove the virtual keyword from set_update_interval and inline the
trivial setter in the header. No component in the tree actually
overrides this on PollingComponent — the only apparent override was
in sds011 which extends Component (not PollingComponent), so it was
just a name-hiding no-op that is also removed here.

This allows the compiler to inline the setter at all 8 call sites
generated by register_component, eliminating function call overhead
and removing a vtable entry.
This commit is contained in:
J. Nick Koston
2026-03-18 12:49:42 -10:00
parent 9f4c773963
commit 2ab54174e9
3 changed files with 1 additions and 6 deletions
-2
View File
@@ -21,8 +21,6 @@ class SDS011Component : public Component, public uart::UARTDevice {
void dump_config() override;
void loop() override;
void set_update_interval(uint32_t val) { /* ignore */
}
void set_update_interval_min(uint8_t update_interval_min);
void set_working_state(bool working_state);
-1
View File
@@ -508,7 +508,6 @@ void PollingComponent::stop_poller() {
}
uint32_t PollingComponent::get_update_interval() const { return this->update_interval_; }
void PollingComponent::set_update_interval(uint32_t update_interval) { this->update_interval_ = update_interval; }
void __attribute__((noinline, cold))
WarnIfComponentBlockingGuard::warn_blocking(Component *component, uint32_t blocking_time) {
+1 -3
View File
@@ -548,12 +548,10 @@ class PollingComponent : public Component {
explicit PollingComponent(uint32_t update_interval);
/** Manually set the update interval in ms for this polling object.
*
* Override this if you want to do some validation for the update interval.
*
* @param update_interval The update interval in ms.
*/
virtual void set_update_interval(uint32_t update_interval);
void set_update_interval(uint32_t update_interval) { this->update_interval_ = update_interval; }
// ========== OVERRIDE METHODS ==========
// (You'll only need this when creating your own custom sensor)