aboutsummaryrefslogtreecommitdiffstats
path: root/timer.c
diff options
context:
space:
mode:
authormzuther <mzuther@3ae390bd-cb1e-0410-b409-cd5a39f66f1f>2010-02-07 20:45:51 +0000
committermzuther <mzuther@3ae390bd-cb1e-0410-b409-cd5a39f66f1f>2010-02-07 20:45:51 +0000
commitb35fc3f8cbd2ddda61fc256e771c61efc0457a59 (patch)
tree05c8fce4dc82767107c2c0c416be75c7bbc03491 /timer.c
parent7496af7c8678b4ee97f9913b26dad028149eed79 (diff)
downloadlcd4linux-b35fc3f8cbd2ddda61fc256e771c61efc0457a59.tar.gz
timer.c: two small optimizations (removed "flag"; tv_usec can't be negative)
git-svn-id: https://ssl.bulix.org/svn/lcd4linux/trunk@1107 3ae390bd-cb1e-0410-b409-cd5a39f66f1f
Diffstat (limited to 'timer.c')
-rw-r--r--timer.c11
1 files changed, 4 insertions, 7 deletions
diff --git a/timer.c b/timer.c
index 212c392..80d2521 100644
--- a/timer.c
+++ b/timer.c
@@ -156,7 +156,7 @@ int timer_add(void (*callback) (void *data), void *data, const int interval, con
int timer_process(struct timespec *delay)
{
- int i, flag, min;
+ int i, min;
struct timeval now;
/* the current moment */
@@ -187,15 +187,12 @@ int timer_process(struct timespec *delay)
}
/* find next timer */
- flag = 1;
min = -1;
for (i = 0; i < nTimers; i++) {
if (Timers[i].active == 0)
continue;
- if (flag || timercmp(&Timers[i].when, &Timers[min].when, <)) {
- flag = 0;
+ if ((min < 0) || timercmp(&Timers[i].when, &Timers[min].when, <))
min = i;
- }
}
if (min < 0) {
@@ -211,8 +208,8 @@ int timer_process(struct timespec *delay)
timersub(&Timers[min].when, &now, &diff);
/* for negative delays, directly trigger next update */
- if ((diff.tv_sec < 0) || (diff.tv_usec < 0))
- timerclear(&diff);
+ if (diff.tv_sec < 0)
+ timerclear(&diff);
delay->tv_sec = diff.tv_sec;
/* microseconds to nanoseconds!! */