MultiTimerYield optimize.

development
0x1abin 4 years ago
parent 180ccdddd3
commit ae72a97e89

@ -69,23 +69,18 @@ int MultiTimerStop(MultiTimer* timer)
int MultiTimerYield(void) int MultiTimerYield(void)
{ {
MultiTimer** nextTimer = &timerList; MultiTimer* entry = timerList;
for (; *nextTimer; nextTimer = &(*nextTimer)->next) { for (; entry; entry = entry->next) {
MultiTimer* entry = *nextTimer;
/* Sorted list, just process with the front part. */ /* Sorted list, just process with the front part. */
if (CHECK_TIME_LESS_THAN(platformTicksFunction(), entry->deadline)) { if (CHECK_TIME_LESS_THAN(platformTicksFunction(), entry->deadline)) {
return (int)(entry->deadline - platformTicksFunction()); return (int)(entry->deadline - platformTicksFunction());
} }
/* remove expired timer from list */ /* remove expired timer from list */
*nextTimer = entry->next; timerList = entry->next;
/* call callback */ /* call callback */
if (entry->callback) { if (entry->callback) {
entry->callback(entry, entry->userData); entry->callback(entry, entry->userData);
} }
if (entry->next == NULL) {
return 0;
}
} }
return 0;
} }

Loading…
Cancel
Save