mirror of
https://github.com/joeycastillo/second-movement.git
synced 2026-02-04 16:05:44 +00:00
use __builtin_ctz when processing pending events
This commit is contained in:
@ -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
|
||||||
|
|||||||
Reference in New Issue
Block a user