Skip to content

Commit 543766f

Browse files
committed
Expired check ALWAYS executes yield policy BEFORE checking expiration - that's wasted time.
Expired keeps executing yield policy on already expired oneShot - that's counter intuitive and wasted time.
1 parent 7e429cc commit 543766f

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

cores/esp8266/PolledTimeout.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -157,10 +157,9 @@ class timeoutTemplate
157157
IRAM_ATTR // fast
158158
bool expired()
159159
{
160-
YieldPolicyT::execute(); //in case of DoNothing: gets optimized away
161-
if(PeriodicT) //in case of false: gets optimized away
162-
return expiredRetrigger();
163-
return expiredOneShot();
160+
bool hasExpired = PeriodicT ? expiredRetrigger() : expiredOneShot();
161+
if (!hasExpired) YieldPolicyT::execute(); //in case of DoNothing: gets optimized away
162+
return hasExpired;
164163
}
165164

166165
IRAM_ATTR // fast

0 commit comments

Comments
 (0)