use __builtin_ctz when processing pending events

This commit is contained in:
Alessandro Genova
2025-09-12 21:41:59 -04:00
parent e5ddbe3c10
commit 13a5166097

View File

@ -1223,12 +1223,11 @@ bool app_loop(void) {
// Consume all the pending events // Consume all the pending events
movement_event_type_t event_type = 0; movement_event_type_t event_type = 0;
while (pending_events) { while (pending_events) {
if (pending_events & 1) { uint8_t next_event = __builtin_ctz(pending_events);
event.event_type = event_type; event.event_type = event_type + next_event;
can_sleep = wf->loop(event, watch_face_contexts[movement_state.current_face_idx]) && can_sleep; can_sleep = wf->loop(event, watch_face_contexts[movement_state.current_face_idx]) && can_sleep;
} pending_events = pending_events >> (next_event + 1);
pending_events = pending_events >> 1; event_type = event_type + next_event + 1;
event_type++;
} }
// handle top-of-minute tasks, if the alarm handler told us we need to // handle top-of-minute tasks, if the alarm handler told us we need to