Skip to content

Commit 853eb53

Browse files
authored
chore(swc_allocator): Add #[inline] to allocator methods (#10066)
**Description:** It's necessary for allocators, for an unknown reason
1 parent 52caf23 commit 853eb53

File tree

1 file changed

+12
-0
lines changed
  • crates/swc_allocator/src/allocators

1 file changed

+12
-0
lines changed

Diff for: crates/swc_allocator/src/allocators/arena.rs

+12
Original file line numberDiff line numberDiff line change
@@ -30,24 +30,28 @@ impl From<Bump> for Arena {
3030

3131
#[cfg(feature = "nightly")]
3232
unsafe impl std::alloc::Allocator for &'_ Arena {
33+
#[inline]
3334
fn allocate(
3435
&self,
3536
layout: std::alloc::Layout,
3637
) -> Result<std::ptr::NonNull<[u8]>, std::alloc::AllocError> {
3738
std::alloc::Allocator::allocate(&&self.inner, layout)
3839
}
3940

41+
#[inline]
4042
unsafe fn deallocate(&self, ptr: std::ptr::NonNull<u8>, layout: std::alloc::Layout) {
4143
std::alloc::Allocator::deallocate(&&self.inner, ptr, layout)
4244
}
4345

46+
#[inline]
4447
fn allocate_zeroed(
4548
&self,
4649
layout: std::alloc::Layout,
4750
) -> Result<std::ptr::NonNull<[u8]>, std::alloc::AllocError> {
4851
std::alloc::Allocator::allocate_zeroed(&&self.inner, layout)
4952
}
5053

54+
#[inline]
5155
unsafe fn grow(
5256
&self,
5357
ptr: std::ptr::NonNull<u8>,
@@ -57,6 +61,7 @@ unsafe impl std::alloc::Allocator for &'_ Arena {
5761
std::alloc::Allocator::grow(&&self.inner, ptr, old_layout, new_layout)
5862
}
5963

64+
#[inline]
6065
unsafe fn grow_zeroed(
6166
&self,
6267
ptr: std::ptr::NonNull<u8>,
@@ -66,6 +71,7 @@ unsafe impl std::alloc::Allocator for &'_ Arena {
6671
std::alloc::Allocator::grow_zeroed(&&self.inner, ptr, old_layout, new_layout)
6772
}
6873

74+
#[inline]
6975
unsafe fn shrink(
7076
&self,
7177
ptr: std::ptr::NonNull<u8>,
@@ -78,24 +84,28 @@ unsafe impl std::alloc::Allocator for &'_ Arena {
7884

7985
#[cfg(not(feature = "nightly"))]
8086
unsafe impl allocator_api2::alloc::Allocator for &'_ Arena {
87+
#[inline]
8188
fn allocate(
8289
&self,
8390
layout: std::alloc::Layout,
8491
) -> Result<std::ptr::NonNull<[u8]>, allocator_api2::alloc::AllocError> {
8592
allocator_api2::alloc::Allocator::allocate(&&self.inner, layout)
8693
}
8794

95+
#[inline]
8896
unsafe fn deallocate(&self, ptr: std::ptr::NonNull<u8>, layout: std::alloc::Layout) {
8997
allocator_api2::alloc::Allocator::deallocate(&&self.inner, ptr, layout)
9098
}
9199

100+
#[inline]
92101
fn allocate_zeroed(
93102
&self,
94103
layout: std::alloc::Layout,
95104
) -> Result<std::ptr::NonNull<[u8]>, allocator_api2::alloc::AllocError> {
96105
allocator_api2::alloc::Allocator::allocate_zeroed(&&self.inner, layout)
97106
}
98107

108+
#[inline]
99109
unsafe fn grow(
100110
&self,
101111
ptr: std::ptr::NonNull<u8>,
@@ -105,6 +115,7 @@ unsafe impl allocator_api2::alloc::Allocator for &'_ Arena {
105115
allocator_api2::alloc::Allocator::grow(&&self.inner, ptr, old_layout, new_layout)
106116
}
107117

118+
#[inline]
108119
unsafe fn grow_zeroed(
109120
&self,
110121
ptr: std::ptr::NonNull<u8>,
@@ -114,6 +125,7 @@ unsafe impl allocator_api2::alloc::Allocator for &'_ Arena {
114125
allocator_api2::alloc::Allocator::grow_zeroed(&&self.inner, ptr, old_layout, new_layout)
115126
}
116127

128+
#[inline]
117129
unsafe fn shrink(
118130
&self,
119131
ptr: std::ptr::NonNull<u8>,

0 commit comments

Comments
 (0)