Skip to content

Commit

Permalink
Merge pull request #223 from Kmeakin/allocator-methods-inline
Browse files Browse the repository at this point in the history
Annotate `Allocator` methods with `#[inline]`
  • Loading branch information
fitzgen authored Jan 2, 2024
2 parents c0b1137 + e6a7eb0 commit 871e3b3
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1875,6 +1875,7 @@ unsafe impl<'a> alloc::Alloc for &'a Bump {

#[cfg(any(feature = "allocator_api", feature = "allocator-api2"))]
unsafe impl<'a> Allocator for &'a Bump {
#[inline]
fn allocate(&self, layout: Layout) -> Result<NonNull<[u8]>, AllocError> {
self.try_alloc_layout(layout)
.map(|p| unsafe {
Expand All @@ -1883,10 +1884,12 @@ unsafe impl<'a> Allocator for &'a Bump {
.map_err(|_| AllocError)
}

#[inline]
unsafe fn deallocate(&self, ptr: NonNull<u8>, layout: Layout) {
Bump::dealloc(self, ptr, layout)
}

#[inline]
unsafe fn shrink(
&self,
ptr: NonNull<u8>,
Expand All @@ -1900,6 +1903,7 @@ unsafe impl<'a> Allocator for &'a Bump {
.map_err(|_| AllocError)
}

#[inline]
unsafe fn grow(
&self,
ptr: NonNull<u8>,
Expand All @@ -1913,6 +1917,7 @@ unsafe impl<'a> Allocator for &'a Bump {
.map_err(|_| AllocError)
}

#[inline]
unsafe fn grow_zeroed(
&self,
ptr: NonNull<u8>,
Expand Down

0 comments on commit 871e3b3

Please sign in to comment.