Skip to content

Commit e66de41

Browse files
committed
refactor(allocator/pool): AllocatorPool::new always create standard pool
1 parent 90ff7e9 commit e66de41

File tree

2 files changed

+11
-13
lines changed

2 files changed

+11
-13
lines changed

crates/oxc_allocator/src/pool/mod.rs

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,21 @@ pub use standard::{FixedSizeAllocatorMetadata, free_fixed_size_allocator};
4343

4444
/// A thread-safe pool for reusing [`Allocator`] instances to reduce allocation overhead.
4545
///
46-
/// Uses either a standard or fixed-size allocator pool implementation, depending on Cargo features
47-
/// and platform support.
46+
/// Uses either:
47+
/// 1. Standard allocators - suitable for general use.
48+
/// 2. Fixed-size allocators - compatible with raw transfer.
49+
///
50+
/// Standard allocator pool is created by [`AllocatorPool::new`].
51+
/// Fixed-size allocator pool is created by [`AllocatorPool::new_fixed_size`].
52+
///
53+
/// Fixed-size allocators are only supported on 64-bit little-endian platforms at present,
54+
/// and require the `fixed_size` Cargo feature to be enabled, and `disable_fixed_size` Cargo feature
55+
/// to not be enabled.
4856
#[repr(transparent)]
4957
pub struct AllocatorPool(AllocatorPoolInner);
5058

5159
/// Inner type of [`AllocatorPool`], holding either a standard or fixed-size allocator pool.
5260
enum AllocatorPoolInner {
53-
#[cfg_attr(all(feature = "fixed_size", not(feature = "disable_fixed_size")), expect(dead_code))]
5461
Standard(StandardAllocatorPool),
5562
#[cfg(all(
5663
feature = "fixed_size",
@@ -65,15 +72,7 @@ impl AllocatorPool {
6572
/// Create a new [`AllocatorPool`] for use across the specified number of threads,
6673
/// which uses either standard or fixed-size allocators depending on Cargo features.
6774
pub fn new(thread_count: usize) -> AllocatorPool {
68-
#[cfg(all(feature = "fixed_size", not(feature = "disable_fixed_size")))]
69-
{
70-
Self::new_fixed_size(thread_count)
71-
}
72-
73-
#[cfg(not(all(feature = "fixed_size", not(feature = "disable_fixed_size"))))]
74-
{
75-
Self(AllocatorPoolInner::Standard(StandardAllocatorPool::new(thread_count)))
76-
}
75+
Self(AllocatorPoolInner::Standard(StandardAllocatorPool::new(thread_count)))
7776
}
7877

7978
/// Create a new [`AllocatorPool`] for use across the specified number of threads,

crates/oxc_allocator/src/pool/standard.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ pub struct StandardAllocatorPool {
1212

1313
impl StandardAllocatorPool {
1414
/// Create a new [`StandardAllocatorPool`] for use across the specified number of threads.
15-
#[cfg_attr(all(feature = "fixed_size", not(feature = "disable_fixed_size")), expect(dead_code))]
1615
pub fn new(thread_count: usize) -> StandardAllocatorPool {
1716
let allocators = iter::repeat_with(Allocator::new).take(thread_count).collect();
1817
StandardAllocatorPool { allocators: Mutex::new(allocators) }

0 commit comments

Comments
 (0)