diff options
| author | Keith Packard <keithp@keithp.com> | 2012-03-27 18:19:05 -0700 | 
|---|---|---|
| committer | Keith Packard <keithp@keithp.com> | 2012-03-27 18:19:05 -0700 | 
| commit | 7dd1d62676c1e605fe69a4c0acfe7638c6b79aa5 (patch) | |
| tree | 5f42dc087107cfa07b8fd32fb1df89ad2117ed35 | |
| parent | d77a4ea206d627635159f35c76c744687d4e633b (diff) | |
altos: Optimize ao_freq_to_set a bit
Reduces size from 327 bytes to 287 bytes
Signed-off-by: Keith Packard <keithp@keithp.com>
| -rw-r--r-- | src/core/ao_freq.c | 8 | 
1 files 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) | 
