Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions crates/oxc_allocator/src/pool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ pub struct AllocatorPool {
}

impl AllocatorPool {
/// Creates a new [`AllocatorPool`] pre-filled with the given number of default [`Allocator`] instances.
pub fn new(size: usize) -> AllocatorPool {
let allocators = iter::repeat_with(Allocator::new).take(size).collect();
/// Creates a new [`AllocatorPool`] for use across the specified number of threads.
pub fn new(thread_count: usize) -> AllocatorPool {
let allocators = iter::repeat_with(Allocator::new).take(thread_count).collect();
AllocatorPool { allocators: Mutex::new(allocators) }
}

Expand Down
9 changes: 5 additions & 4 deletions crates/oxc_allocator/src/pool_fixed_size.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,11 @@ pub struct AllocatorPool {
}

impl AllocatorPool {
/// Creates a new [`AllocatorPool`] with capacity for the given number of `FixedSizeAllocator` instances.
pub fn new(size: usize) -> AllocatorPool {
// Each allocator consumes a large block of memory, so create them on demand instead of upfront
let allocators = Vec::with_capacity(size);
/// Creates a new [`AllocatorPool`] for use across the specified number of threads.
pub fn new(thread_count: usize) -> AllocatorPool {
// Each allocator consumes a large block of memory, so create them on demand instead of upfront,
// in case not all threads end up being used (e.g. language server without `import` plugin)
let allocators = Vec::with_capacity(thread_count);
AllocatorPool { allocators: Mutex::new(allocators), next_id: AtomicU32::new(0) }
}

Expand Down
Loading