Skip to content

Commit da95451

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 e1e34ce commit da95451

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
@@ -158,10 +158,9 @@ class timeoutTemplate
158158
IRAM_ATTR // fast
159159
bool expired()
160160
{
161-
YieldPolicyT::execute(); //in case of DoNothing: gets optimized away
162-
if(PeriodicT) //in case of false: gets optimized away
163-
return expiredRetrigger();
164-
return expiredOneShot();
161+
bool hasExpired = PeriodicT ? expiredRetrigger() : expiredOneShot();
162+
if (!hasExpired) YieldPolicyT::execute(); //in case of DoNothing: gets optimized away
163+
return hasExpired;
165164
}
166165

167166
IRAM_ATTR // fast

0 commit comments

Comments
 (0)