wasm backends: Avoid a heap allocation in default_output_config()
This commit is contained in:
parent
b5b6014edf
commit
0b300afefe
2 changed files with 10 additions and 10 deletions
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -121,13 +121,13 @@ impl Device {
|
|||
#[inline]
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue