@@ -28,6 +28,7 @@ use crate::{
2828 fixer:: PossibleFixes ,
2929 loader:: { JavaScriptSource , LINT_PARTIAL_LOADER_EXTENSIONS , PartialLoader } ,
3030 module_record:: ModuleRecord ,
31+ pool:: { self , Pool } ,
3132 utils:: read_to_string,
3233} ;
3334
@@ -42,6 +43,8 @@ pub struct Runtime<'l> {
4243 resolver : Option < Resolver > ,
4344
4445 pub ( super ) file_system : Box < dyn RuntimeFileSystem + Sync + Send > ,
46+
47+ allocator_pool : Pool < Allocator > ,
4548}
4649
4750/// Output of `Runtime::process_path`
@@ -95,7 +98,7 @@ unsafe impl Send for ModuleContent {}
9598
9699struct ModuleContentOwner {
97100 source_text : String ,
98- allocator : Allocator ,
101+ allocator : pool :: PoolGuard < Allocator > ,
99102}
100103
101104/// source text and semantic for each source section. They are in the same order as `ProcessedModule.section_module_records`
@@ -165,6 +168,7 @@ impl<'l> Runtime<'l> {
165168 Self :: get_resolver ( options. tsconfig . or_else ( || Some ( options. cwd . join ( "tsconfig.json" ) ) ) )
166169 } ) ;
167170 Self {
171+ allocator_pool : Pool :: new ( Allocator :: default) ,
168172 cwd : options. cwd ,
169173 paths : options. paths . iter ( ) . cloned ( ) . collect ( ) ,
170174 linter,
@@ -771,7 +775,9 @@ impl<'l> Runtime<'l> {
771775 } ;
772776 let mut records = SmallVec :: < [ Result < ResolvedModuleRecord , Vec < OxcDiagnostic > > ; 1 ] > :: new ( ) ;
773777 let mut module_content: Option < ModuleContent > = None ;
774- let allocator = Allocator :: default ( ) ;
778+
779+ let allocator = self . allocator_pool . get ( ) ;
780+
775781 if self . paths . contains ( path) {
776782 module_content =
777783 Some ( ModuleContent :: new ( ModuleContentOwner { source_text, allocator } , |owner| {
0 commit comments