Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

5) rust: use borrow in compute interface #1087

Open
wants to merge 12 commits into
base: master-dev
Choose a base branch
from

Conversation

crop2000
Copy link
Contributor

the current compute function signature looks like this:

	pub fn compute(&mut self, count: usize, inputs: &[&[FaustFloat]], outputs: &mut [&mut [FaustFloat]]){

this prevents us from passing a mutable reference as input buffer slice.
in the case one wants to chain dsps where the outputs of one dsp are used as the input of another it would be good if one can pass pass same slice that is used as the output of one dsp as input of another. but in that case one would pass a mutable reference. which is not possible with the current function signature.
this pr changes the functions to be more general. so that one can pass a mutable reference to the the input.
The new now looks like this:

	pub fn compute<InType, OutType>(
		&mut self,
		count: usize,
		inputs: impl borrow::Borrow<[InType]>,
		mut outputs: impl borrow::BorrowMut<[OutType]>,
	) where
		InType: borrow::Borrow<[FaustFloat]>,
		OutType: borrow::BorrowMut<[FaustFloat]>,
	{

this change is fully backwards compatible.

Because I found out that my earlier introduced compute_array interface is not contributing to the performance i removed it here again because it would make this change more complicated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant