@@ -42,22 +42,21 @@ pub fn get_map<S: StreamChunks>(
4242 & mut |source_index, source, source_content| {
4343 let source_index = source_index as usize ;
4444 if sources. len ( ) <= source_index {
45- sources. resize ( source_index + 1 , "" . into ( ) ) ;
45+ sources. resize ( source_index + 1 , "" . to_string ( ) ) ;
4646 }
4747 sources[ source_index] = source. to_string ( ) ;
4848 if let Some ( source_content) = source_content {
4949 if sources_content. len ( ) <= source_index {
50- sources_content. resize ( source_index + 1 , "" . into ( ) ) ;
50+ sources_content. resize ( source_index + 1 , "" . to_string ( ) ) ;
5151 }
52- // TODO: avoid to_string allocation
5352 sources_content[ source_index] = source_content. to_string ( ) ;
5453 }
5554 } ,
5655 // on_name
5756 & mut |name_index, name| {
5857 let name_index = name_index as usize ;
5958 if names. len ( ) <= name_index {
60- names. resize ( name_index + 1 , "" . into ( ) ) ;
59+ names. resize ( name_index + 1 , "" . to_string ( ) ) ;
6160 }
6261 names[ name_index] = name. to_string ( ) ;
6362 } ,
@@ -1220,7 +1219,6 @@ pub fn stream_and_get_source_and_map<'a, S: StreamChunks>(
12201219 while sources_content. len ( ) <= source_index2 {
12211220 sources_content. push ( "" . into ( ) ) ;
12221221 }
1223- // TODO: avoid allocation here
12241222 sources_content[ source_index2] = source_content. to_string ( ) ;
12251223 }
12261224 on_source ( source_index, source, source_content) ;
@@ -1239,12 +1237,7 @@ pub fn stream_and_get_source_and_map<'a, S: StreamChunks>(
12391237 let map = if mappings. is_empty ( ) {
12401238 None
12411239 } else {
1242- Some ( SourceMap :: new (
1243- mappings. to_string ( ) ,
1244- sources,
1245- sources_content,
1246- names,
1247- ) )
1240+ Some ( SourceMap :: new ( mappings, sources, sources_content, names) )
12481241 } ;
12491242 ( generated_info, map)
12501243}
0 commit comments