Optimize pdm_continuous example

This commit is contained in:
Quentin Smith 2022-08-21 12:40:51 -04:00
parent 64154fec8c
commit 14eae9ca06

View File

@ -68,8 +68,9 @@ fn fft_peak_freq(input: &[i16; 1024]) -> (usize, u32) {
result
.iter()
.map(|c| ((c.norm_sqr()*32768.0) as u32).sqrt())
.map(|c| c.norm_sqr())
.enumerate()
.max_by(|(_, a), (_, b)| a.partial_cmp(b).unwrap_or(Ordering::Equal))
.map(|(i, v)| (i, ((v*32768.0) as u32).sqrt()))
.unwrap()
}
}