From: Keith Packard Date: Wed, 28 Mar 2012 01:19:05 +0000 (-0700) Subject: altos: Optimize ao_freq_to_set a bit X-Git-Tag: 1.0.9.4~47 X-Git-Url: https://git.gag.com/?a=commitdiff_plain;h=7dd1d62676c1e605fe69a4c0acfe7638c6b79aa5;hp=d77a4ea206d627635159f35c76c744687d4e633b;p=fw%2Faltos altos: Optimize ao_freq_to_set a bit Reduces size from 327 bytes to 287 bytes Signed-off-by: Keith Packard --- 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)