@@ -12,7 +12,7 @@ use crate::{
1212 decoder:: MappingsDecoder ,
1313 encoder:: create_encoder,
1414 linear_map:: LinearMap ,
15- object_pool:: with_current_thread_object_pool_scope ,
15+ object_pool:: ObjectPool ,
1616 source:: { Mapping , OriginalLocation } ,
1717 source_content_lines:: SourceContentLines ,
1818 with_indices:: WithIndices ,
@@ -22,13 +22,6 @@ use crate::{
2222pub fn get_map < ' a , S : StreamChunks > (
2323 stream : & ' a S ,
2424 options : & ' a MapOptions ,
25- ) -> Option < SourceMap > {
26- with_current_thread_object_pool_scope ( || get_map_impl ( stream, options) )
27- }
28-
29- pub fn get_map_impl < ' a , S : StreamChunks > (
30- stream : & ' a S ,
31- options : & ' a MapOptions ,
3225) -> Option < SourceMap > {
3326 let mut mappings_encoder = create_encoder ( options. columns ) ;
3427 let mut sources: Vec < String > = Vec :: new ( ) ;
@@ -40,6 +33,7 @@ pub fn get_map_impl<'a, S: StreamChunks>(
4033 columns : options. columns ,
4134 final_source : true ,
4235 } ,
36+ & ObjectPool :: default ( ) ,
4337 // on_chunk
4438 & mut |_, mapping| {
4539 mappings_encoder. encode ( & mapping) ;
@@ -78,6 +72,7 @@ pub trait StreamChunks {
7872 fn stream_chunks < ' a > (
7973 & ' a self ,
8074 options : & MapOptions ,
75+ object_pool : & ' a ObjectPool ,
8176 on_chunk : OnChunk < ' _ , ' a > ,
8277 on_source : OnSource < ' _ , ' a > ,
8378 on_name : OnName < ' _ , ' a > ,
@@ -97,9 +92,10 @@ pub type OnName<'a, 'b> = &'a mut dyn FnMut(u32, Cow<'b, str>);
9792
9893/// Default stream chunks behavior impl, see [webpack-sources streamChunks](https://github.com/webpack/webpack-sources/blob/9f98066311d53a153fdc7c633422a1d086528027/lib/helpers/streamChunks.js#L15-L35).
9994pub fn stream_chunks_default < ' a , S > (
95+ options : & MapOptions ,
96+ object_pool : & ' a ObjectPool ,
10097 source : S ,
10198 source_map : Option < & ' a SourceMap > ,
102- options : & MapOptions ,
10399 on_chunk : OnChunk < ' _ , ' a > ,
104100 on_source : OnSource < ' _ , ' a > ,
105101 on_name : OnName < ' _ , ' a > ,
@@ -109,7 +105,13 @@ where
109105{
110106 if let Some ( map) = source_map {
111107 stream_chunks_of_source_map (
112- source, map, on_chunk, on_source, on_name, options,
108+ options,
109+ object_pool,
110+ source,
111+ map,
112+ on_chunk,
113+ on_source,
114+ on_name,
113115 )
114116 } else {
115117 stream_chunks_of_raw_source ( source, options, on_chunk, on_source, on_name)
@@ -308,12 +310,13 @@ where
308310}
309311
310312pub fn stream_chunks_of_source_map < ' a , S > (
313+ options : & MapOptions ,
314+ object_pool : & ' a ObjectPool ,
311315 source : S ,
312316 source_map : & ' a SourceMap ,
313317 on_chunk : OnChunk < ' _ , ' a > ,
314318 on_source : OnSource < ' _ , ' a > ,
315319 on_name : OnName < ' _ , ' a > ,
316- options : & MapOptions ,
317320) -> GeneratedInfo
318321where
319322 S : SourceText < ' a > + ' a ,
@@ -322,24 +325,33 @@ where
322325 MapOptions {
323326 columns : true ,
324327 final_source : true ,
328+ ..
325329 } => stream_chunks_of_source_map_final (
326330 source, source_map, on_chunk, on_source, on_name,
327331 ) ,
328332 MapOptions {
329333 columns : true ,
330334 final_source : false ,
335+ ..
331336 } => stream_chunks_of_source_map_full (
332- source, source_map, on_chunk, on_source, on_name,
337+ object_pool,
338+ source,
339+ source_map,
340+ on_chunk,
341+ on_source,
342+ on_name,
333343 ) ,
334344 MapOptions {
335345 columns : false ,
336346 final_source : true ,
347+ ..
337348 } => stream_chunks_of_source_map_lines_final (
338349 source, source_map, on_chunk, on_source, on_name,
339350 ) ,
340351 MapOptions {
341352 columns : false ,
342353 final_source : false ,
354+ ..
343355 } => stream_chunks_of_source_map_lines_full (
344356 source, source_map, on_chunk, on_source, on_name,
345357 ) ,
@@ -418,6 +430,7 @@ where
418430}
419431
420432fn stream_chunks_of_source_map_full < ' a , S > (
433+ object_pool : & ' a ObjectPool ,
421434 source : S ,
422435 source_map : & ' a SourceMap ,
423436 on_chunk : OnChunk < ' _ , ' a > ,
@@ -428,7 +441,9 @@ where
428441 S : SourceText < ' a > + ' a ,
429442{
430443 let lines = split_into_lines ( & source) ;
431- let line_with_indices_list = lines. map ( WithIndices :: new) . collect :: < Vec < _ > > ( ) ;
444+ let line_with_indices_list = lines
445+ . map ( |line| WithIndices :: new ( object_pool, line) )
446+ . collect :: < Vec < _ > > ( ) ;
432447
433448 if line_with_indices_list. is_empty ( ) {
434449 return GeneratedInfo {
@@ -715,6 +730,8 @@ type InnerSourceIndexValueMapping<'a> =
715730
716731#[ allow( clippy:: too_many_arguments) ]
717732pub fn stream_chunks_of_combined_source_map < ' a , S > (
733+ options : & MapOptions ,
734+ object_pool : & ' a ObjectPool ,
718735 source : S ,
719736 source_map : & ' a SourceMap ,
720737 inner_source_name : & ' a str ,
@@ -724,7 +741,6 @@ pub fn stream_chunks_of_combined_source_map<'a, S>(
724741 on_chunk : OnChunk < ' _ , ' a > ,
725742 on_source : OnSource < ' _ , ' a > ,
726743 on_name : OnName < ' _ , ' a > ,
727- options : & MapOptions ,
728744) -> GeneratedInfo
729745where
730746 S : SourceText < ' a > + ' a ,
@@ -781,6 +797,8 @@ where
781797 } ;
782798
783799 stream_chunks_of_source_map (
800+ options,
801+ object_pool,
784802 source. clone ( ) ,
785803 source_map,
786804 & mut |chunk, mapping| {
@@ -835,7 +853,10 @@ where
835853 let inner_source_contents = inner_source_contents. borrow ( ) ;
836854 match inner_source_contents. get ( & inner_source_index) {
837855 Some ( Some ( source_content) ) => {
838- Some ( SourceContentLines :: from ( source_content. clone ( ) ) )
856+ Some ( SourceContentLines :: from (
857+ object_pool,
858+ source_content. clone ( ) ,
859+ ) )
839860 }
840861 _ => None ,
841862 }
@@ -934,7 +955,10 @@ where
934955 let inner_source_contents = inner_source_contents. borrow ( ) ;
935956 match inner_source_contents. get ( & inner_source_index) {
936957 Some ( Some ( source_content) ) => {
937- Some ( SourceContentLines :: from ( source_content. clone ( ) ) )
958+ Some ( SourceContentLines :: from (
959+ object_pool,
960+ source_content. clone ( ) ,
961+ ) )
938962 }
939963 _ => None ,
940964 }
@@ -1098,6 +1122,11 @@ where
10981122 }
10991123 source_index_mapping. borrow_mut ( ) . insert ( i, -2 ) ;
11001124 stream_chunks_of_source_map (
1125+ & MapOptions {
1126+ columns : options. columns ,
1127+ final_source : false ,
1128+ } ,
1129+ object_pool,
11011130 source_content. unwrap ( ) . as_ref ( ) ,
11021131 inner_source_map,
11031132 & mut |chunk, mapping| {
@@ -1167,10 +1196,6 @@ where
11671196 inner_name_index_mapping. borrow_mut ( ) . insert ( i, -2 ) ;
11681197 inner_name_index_value_mapping. borrow_mut ( ) . insert ( i, name) ;
11691198 } ,
1170- & MapOptions {
1171- columns : options. columns ,
1172- final_source : false ,
1173- } ,
11741199 ) ;
11751200 } else {
11761201 let mut source_mapping = source_mapping. borrow_mut ( ) ;
@@ -1190,13 +1215,13 @@ where
11901215 name_index_mapping. borrow_mut ( ) . insert ( i, -2 ) ;
11911216 name_index_value_mapping. borrow_mut ( ) . insert ( i, name) ;
11921217 } ,
1193- options,
11941218 )
11951219}
11961220
11971221pub fn stream_and_get_source_and_map < ' a , S : StreamChunks > (
1198- input_source : & ' a S ,
11991222 options : & MapOptions ,
1223+ object_pool : & ' a ObjectPool ,
1224+ input_source : & ' a S ,
12001225 on_chunk : OnChunk < ' _ , ' a > ,
12011226 on_source : OnSource < ' _ , ' a > ,
12021227 on_name : OnName < ' _ , ' a > ,
@@ -1208,6 +1233,7 @@ pub fn stream_and_get_source_and_map<'a, S: StreamChunks>(
12081233
12091234 let generated_info = input_source. stream_chunks (
12101235 options,
1236+ object_pool,
12111237 & mut |chunk, mapping| {
12121238 mappings_encoder. encode ( & mapping) ;
12131239 on_chunk ( chunk, mapping) ;
0 commit comments