Minor optimization.

git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@14366 27425a3e-05d8-49a3-a47f-9c15f0e5edd8
This commit is contained in:
Giovanni Di Sirio 2021-05-11 11:53:15 +00:00
parent 27874273d4
commit 1ebfbbaa50
1 changed files with 8 additions and 4 deletions

View File

@ -264,13 +264,16 @@ void chVTDoResetI(virtual_timer_t *vtp) {
(void) ch_dlist_dequeue(&vtp->dlist);
/* Adding delta to the next element, if it is not the last one.*/
if (is_timer(&vtlp->dlist, vtp->dlist.next)) {
vtp->dlist.next->delta += vtp->dlist.delta;
}
vtp->dlist.next->delta += vtp->dlist.delta;
/* Marking timer as not armed.*/
vtp->dlist.next = NULL;
/* Special case when the removed element from the last position in the list,
the value in the header must be restored, just doing it is faster than
checking then doing.*/
vtlp->dlist.delta = (sysinterval_t)-1;
return;
}
@ -416,6 +419,7 @@ void chVTDoTickI(void) {
lasttime = chTimeAddX(vtlp->lasttime, dlp->delta);
vtlp->lasttime = lasttime;
// TODO, remove this assert, it is triggered also by some valid cases.
chDbgAssert((int)chTimeDiffX(vtlp->lasttime, now) >= 0, "back in time");
/* Removing the timer from the list, marking it as not armed.*/
@ -434,7 +438,7 @@ void chVTDoTickI(void) {
vtp->func(vtp, vtp->par);
chSysLockFromISR();
/* Delta between current time after callback and last execution time.*/
/* Delta between current time after callback execution time.*/
now = chVTGetSystemTimeX();
nowdelta = chTimeDiffX(lasttime, now);