Optimization and refactoring often introduce a tempting branch:
if newState == oldState then return end
S3maphore learned why that is not automatically safe.
Commit fbe9f127 fixed silence-chance handling that had stopped being applied during normal playback after an earlier change. The primary playlist state could remain unchanged while dependent playback state still required refresh.
The rule
Before adding a “nothing changed” fast path, list every side effect attached to the transition.
State equality in one field does not prove that:
- timers are current;
- random/silence decisions are current;
- dependent caches are current;
- UI is current;
- external observers were notified;
- lifecycle bookkeeping ran.
Fast-path only the work whose preconditions you can prove.
Source: S3ctors S3cret St4sh commit fbe9f127.