Skip to content

Commit c777514

Browse files
committed
refactor(allocator): rename vars and comments in AllocatorPool
1 parent 152f1f9 commit c777514

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

crates/oxc_allocator/src/pool.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ pub struct AllocatorPool {
1010
}
1111

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

crates/oxc_allocator/src/pool_fixed_size.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,11 @@ pub struct AllocatorPool {
3030
}
3131

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

0 commit comments

Comments
 (0)