From 5329a881d8d4d2456b7fd1340196358be2b68895 Mon Sep 17 00:00:00 2001 From: Micah Johnston Date: Mon, 15 Jan 2024 17:58:24 -0600 Subject: [PATCH] add missing #[inline]s to buffer methods --- src/buffers.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/buffers.rs b/src/buffers.rs index 17c3b44..b45912b 100644 --- a/src/buffers.rs +++ b/src/buffers.rs @@ -11,6 +11,7 @@ pub enum BufferDir<'a, 'b> { } impl<'a, 'b> BufferDir<'a, 'b> { + #[inline] pub unsafe fn from_raw_parts( dir: BusDir, ptrs: &'a [*mut f32], @@ -102,6 +103,7 @@ impl<'a, 'b> IntoIterator for Buffers<'a, 'b> { type Item = BufferDir<'a, 'b>; type IntoIter = Buses<'a, 'b>; + #[inline] fn into_iter(self) -> Self::IntoIter { Buses { iter: self.buses.into_iter(), @@ -124,6 +126,7 @@ pub struct Buses<'a, 'b> { impl<'a, 'b> Iterator for Buses<'a, 'b> { type Item = BufferDir<'a, 'b>; + #[inline] fn next(&mut self) -> Option { if let Some(bus) = self.iter.next() { unsafe { @@ -176,6 +179,7 @@ impl<'a, 'b> Buffer<'a, 'b> { impl<'a, 'b> Index for Buffer<'a, 'b> { type Output = [f32]; + #[inline] fn index(&self, index: usize) -> &[f32] { unsafe { slice::from_raw_parts(self.ptrs[index].offset(self.offset), self.len) } } @@ -217,12 +221,14 @@ impl<'a, 'b> BufferMut<'a, 'b> { impl<'a, 'b> Index for BufferMut<'a, 'b> { type Output = [f32]; + #[inline] fn index(&self, index: usize) -> &[f32] { unsafe { slice::from_raw_parts(self.ptrs[index].offset(self.offset), self.len) } } } impl<'a, 'b> IndexMut for BufferMut<'a, 'b> { + #[inline] fn index_mut(&mut self, index: usize) -> &mut [f32] { unsafe { slice::from_raw_parts_mut(self.ptrs[index].offset(self.offset), self.len) } }