Skip to content

Commit

Permalink
Annotate Allocator methods with #[inline]
Browse files Browse the repository at this point in the history
These methods were not annotated with `#[inline]`, meaning they will not be
inlined into client crates unless they enable LTO
  • Loading branch information
Kmeakin committed Dec 29, 2023
1 parent c0b1137 commit e6a7eb0
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 e6a7eb0

Please sign in to comment.