1
0
Fork 0

Rename Block::len() to Block::samples()

For the same reason mentioned in the last commit.
This commit is contained in:
Robbert van der Helm 2023-01-05 16:13:05 +01:00
parent cb2824021b
commit 300e112ede
3 changed files with 7 additions and 7 deletions

View file

@ -10,6 +10,7 @@ code then it will not be listed here.
- `Buffer::len()` has been renamed to `Buffer::samples()` to make this less - `Buffer::len()` has been renamed to `Buffer::samples()` to make this less
ambiguous. ambiguous.
- `Block::len()` has been renamed to `Block::samples()`.
## [2022-11-17] ## [2022-11-17]

View file

@ -126,9 +126,8 @@ impl ExactSizeIterator for BlockChannelsIter<'_, '_> {}
impl<'slice, 'sample> Block<'slice, 'sample> { impl<'slice, 'sample> Block<'slice, 'sample> {
/// Get the number of samples per channel in the block. /// Get the number of samples per channel in the block.
#[allow(clippy::len_without_is_empty)]
#[inline] #[inline]
pub fn len(&self) -> usize { pub fn samples(&self) -> usize {
self.current_block_end - self.current_block_start self.current_block_end - self.current_block_start
} }
@ -231,11 +230,11 @@ impl<'slice, 'sample> Block<'slice, 'sample> {
where where
LaneCount<LANES>: SupportedLaneCount, LaneCount<LANES>: SupportedLaneCount,
{ {
if sample_index > self.len() { if sample_index > self.samples() {
return None; return None;
} }
let used_lanes = self.len().max(LANES); let used_lanes = self.samples().max(LANES);
let mut values = [0.0; LANES]; let mut values = [0.0; LANES];
for (channel_idx, value) in values.iter_mut().enumerate().take(used_lanes) { for (channel_idx, value) in values.iter_mut().enumerate().take(used_lanes) {
*value = unsafe { *value = unsafe {
@ -289,11 +288,11 @@ impl<'slice, 'sample> Block<'slice, 'sample> {
where where
LaneCount<LANES>: SupportedLaneCount, LaneCount<LANES>: SupportedLaneCount,
{ {
if sample_index > self.len() { if sample_index > self.samples() {
return false; return false;
} }
let used_lanes = self.len().max(LANES); let used_lanes = self.samples().max(LANES);
let values = vector.to_array(); let values = vector.to_array();
for (channel_idx, value) in values.into_iter().enumerate().take(used_lanes) { for (channel_idx, value) in values.into_iter().enumerate().take(used_lanes) {
*unsafe { *unsafe {

View file

@ -92,7 +92,7 @@ impl StftInputMut for Buffer<'_> {
impl StftInput for Block<'_, '_> { impl StftInput for Block<'_, '_> {
#[inline] #[inline]
fn num_samples(&self) -> usize { fn num_samples(&self) -> usize {
self.len() self.samples()
} }
#[inline] #[inline]