Skip to content

Conversation

@revmischa
Copy link
Member

@revmischa revmischa commented Nov 3, 2024

ChatGPT recommended using slices because we can avoid extra allocations and ownership transfer when adding PCM data.

  1. Parameter Type:
    • Changed the samples parameter from Vec to &[f32] in both the public and internal methods. This allows you to pass a slice directly without allocating a new Vec.
  2. Ownership:
    • Since slices are borrowed references, there’s no ownership transfer, which is more efficient.
  3. Usage of as_ptr():
    • Slices can still provide a raw pointer using .as_ptr(), so the FFI call remains unchanged.

Might be a breaking change though, if we care

@murl-digital
Copy link
Contributor

It shouldn't be a breaking change, vecs are borrowed as slices automatically in most cases.

@revmischa revmischa merged commit 7fb2aea into master Nov 29, 2024
7 checks passed
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.

2 participants