Skip to content

Commit f4722e7

Browse files
authored
Merge pull request #310 from orottier/feature/needless-clone
Prevent needless clone in offline rendering + in the online happy path
2 parents ddf5e24 + eae1026 commit f4722e7

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

src/render/graph.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@ impl Graph {
354354
}
355355

356356
/// Render a single audio quantum by traversing the node list
357-
pub fn render(&mut self, scope: &RenderScope) -> AudioRenderQuantum {
357+
pub fn render(&mut self, scope: &RenderScope) -> &AudioRenderQuantum {
358358
// if the audio graph was changed, determine the new ordering
359359
if self.ordered.is_empty() {
360360
self.order_nodes();
@@ -460,12 +460,12 @@ impl Graph {
460460
}
461461

462462
// Return the output buffer of destination node
463-
self.nodes
463+
&self
464+
.nodes
464465
.get_mut(&AudioNodeId(0))
465466
.unwrap()
466467
.get_mut()
467468
.outputs[0]
468-
.clone()
469469
}
470470
}
471471

src/render/thread.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -257,8 +257,8 @@ impl RenderThread {
257257
node_id: Cell::new(AudioNodeId(0)), // placeholder value
258258
};
259259

260-
// render audio graph
261-
let mut rendered = self.graph.as_mut().unwrap().render(&scope);
260+
// render audio graph, clone it in case we need to mutate/store the value later
261+
let mut rendered = self.graph.as_mut().unwrap().render(&scope).clone();
262262

263263
// online AudioContext allows channel count to be less than no of hardware channels
264264
if rendered.number_of_channels() != self.number_of_channels {

0 commit comments

Comments
 (0)