mirror of
https://github.com/esphome/esphome.git
synced 2026-05-29 06:27:24 +08:00
[core] Invert feed_wdt condition so slow-path call is inside the if
Cleaner than the early-return form — the action (calling feed_wdt_slow_) reads as the body of the conditional instead of falling through past a guard clause. Logically identical and compiles to the same code.
This commit is contained in:
@@ -398,10 +398,9 @@ class Application {
|
|||||||
/// Pass time==0 to request millis() be read for you (low-frequency callers
|
/// Pass time==0 to request millis() be read for you (low-frequency callers
|
||||||
/// only — always takes the slow path).
|
/// only — always takes the slow path).
|
||||||
void ESPHOME_ALWAYS_INLINE feed_wdt(uint32_t time = 0) {
|
void ESPHOME_ALWAYS_INLINE feed_wdt(uint32_t time = 0) {
|
||||||
if (time != 0 && static_cast<uint32_t>(time - this->last_wdt_feed_) <= WDT_FEED_INTERVAL_MS) {
|
if (time == 0 || static_cast<uint32_t>(time - this->last_wdt_feed_) > WDT_FEED_INTERVAL_MS) {
|
||||||
return;
|
this->feed_wdt_slow_(time);
|
||||||
}
|
}
|
||||||
this->feed_wdt_slow_(time);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void reboot();
|
void reboot();
|
||||||
|
|||||||
Reference in New Issue
Block a user