wasm backends: Avoid a heap allocation in default_output_config()

This commit is contained in:
Rob Watson 2020-09-11 11:34:23 +02:00
parent b5b6014edf
commit 0b300afefe
2 changed files with 10 additions and 10 deletions

View file

@ -103,13 +103,13 @@ impl Device {
fn default_output_config(&self) -> Result<SupportedStreamConfig, DefaultStreamConfigError> {
const EXPECT: &str = "expected at least one valid webaudio stream config";
let mut configs: Vec<_> = self.supported_output_configs().expect(EXPECT).collect();
configs.sort_by(|a, b| a.cmp_default_heuristics(b));
let config = configs
.into_iter()
.last()
let config = self
.supported_output_configs()
.expect(EXPECT)
.max_by(|a, b| a.cmp_default_heuristics(b))
.unwrap()
.with_sample_rate(DEFAULT_SAMPLE_RATE);
Ok(config)
}
}