scripty-bot / scripty

Consider using .clamp(min, max), instead of .max(min).min(max) or .min(max).max(min) RS-W1069
Anti-pattern
Minor
6 months ago7 months old
Consider using .clamp(min, max), instead of .max(min).min(max) or .min(max).max(min)
12	let mut i16_audio = Vec::with_capacity(f32_audio.len());
13	for sample in f32_audio {
14		// clamp the sample to [-1.0, 1.0]
15		let sample = sample.max(-1.0).min(1.0);16		i16_audio.push((sample * i16::MAX as f32) as i16);
17	}
18