aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin O'Connor <kevin@koconnor.net>2017-03-27 13:32:44 -0400
committerKevin O'Connor <kevin@koconnor.net>2017-03-27 13:37:20 -0400
commit31e78c90e2f3c267779237e9cfaa3465e1571a87 (patch)
tree82ed4a67d2a9c9891ffd6af8fd7f2d772143881b
parent3238256b79b3968bfa76e0c8b834231552221615 (diff)
downloadkutter-31e78c90e2f3c267779237e9cfaa3465e1571a87.tar.gz
kutter-31e78c90e2f3c267779237e9cfaa3465e1571a87.tar.xz
kutter-31e78c90e2f3c267779237e9cfaa3465e1571a87.zip
avr: Minor optimization for timer_read_time() / timer_periodic()
Tell the compiler that the TOV1 bit is rarely set. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
-rw-r--r--src/avr/timer.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/avr/timer.c b/src/avr/timer.c
index 2de97526..c9c3ccca 100644
--- a/src/avr/timer.c
+++ b/src/avr/timer.c
@@ -119,7 +119,7 @@ timer_read_time(void)
union u32_u calc;
calc.val = timer_get();
calc.hi = timer_high;
- if (!(TIFR1 & (1<<TOV1))) {
+ if (likely(!(TIFR1 & (1<<TOV1)))) {
irq_restore(flag);
return calc.val;
}
@@ -136,7 +136,7 @@ timer_read_time(void)
void
timer_periodic(void)
{
- if (TIFR1 & (1<<TOV1)) {
+ if (unlikely(TIFR1 & (1<<TOV1))) {
// Hardware timer has overflowed - update overflow counter
TIFR1 = 1<<TOV1;
timer_high++;