From 7dd1d62676c1e605fe69a4c0acfe7638c6b79aa5 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Tue, 27 Mar 2012 18:19:05 -0700 Subject: [PATCH] altos: Optimize ao_freq_to_set a bit Reduces size from 327 bytes to 287 bytes Signed-off-by: Keith Packard --- src/core/ao_freq.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/core/ao_freq.c b/src/core/ao_freq.c index 13bcb383..67b0b037 100644 --- a/src/core/ao_freq.c +++ b/src/core/ao_freq.c @@ -30,20 +30,18 @@ int32_t ao_freq_to_set(int32_t freq, int32_t cal) { uint8_t neg = 0; __pdata int32_t error = -434550 / 2; - freq -= 434550; - if (freq < 0) { + if ((freq -= 434550) < 0) { neg = 1; freq = -freq; } for (;;) { - if (freq == 0 && error <= 0) - break; if (error > 0) { error -= 434550; set++; } else { error += cal; - freq--; + if (--freq < 0) + break; } } if (neg) -- 2.30.2