@@ -2,7 +2,7 @@ use arrayvec::ArrayVec;
22use rustc_hash:: FxHashMap as HashMap ;
33use std:: {
44 borrow:: { BorrowMut , Cow } ,
5- cell:: { OnceCell , RefCell } ,
5+ cell:: RefCell ,
66} ;
77
88use crate :: {
@@ -265,7 +265,7 @@ fn encode_full_mappings(mappings: &[Mapping]) -> String {
265265 let mut initial = true ;
266266
267267 mappings. iter ( ) . fold (
268- String :: with_capacity ( mappings . len ( ) * 6 ) ,
268+ String :: new ( ) ,
269269 |mut acc, mapping| {
270270 if active_mapping && current_line == mapping. generated_line {
271271 // A mapping is still active
@@ -901,29 +901,7 @@ fn stream_chunks_of_source_map_lines_full<'a>(
901901#[ derive( Debug ) ]
902902struct SourceMapLineData < ' a > {
903903 pub mappings_data : Vec < i64 > ,
904- pub chunks : Vec < SourceMapLineChunk < ' a > > ,
905- }
906-
907- #[ derive( Debug ) ]
908- struct SourceMapLineChunk < ' a > {
909- content : Cow < ' a , str > ,
910- cached : OnceCell < WithIndices < Cow < ' a , str > > > ,
911- }
912-
913- impl < ' a > SourceMapLineChunk < ' a > {
914- pub fn new ( content : Cow < ' a , str > ) -> Self {
915- Self {
916- content,
917- cached : OnceCell :: new ( ) ,
918- }
919- }
920-
921- pub fn substring ( & self , start_index : usize , end_index : usize ) -> & str {
922- let cached = self
923- . cached
924- . get_or_init ( || WithIndices :: new ( self . content . clone ( ) ) ) ;
925- cached. substring ( start_index, end_index)
926- }
904+ pub chunks : Vec < WithIndices < Cow < ' a , str > > > ,
927905}
928906
929907type InnerSourceIndexValueMapping < ' a > =
@@ -1355,7 +1333,7 @@ pub fn stream_chunks_of_combined_source_map<'a>(
13551333 . unwrap_or ( -1 ) ,
13561334 ) ;
13571335 // SAFETY: final_source is false
1358- let chunk = SourceMapLineChunk :: new ( chunk. unwrap ( ) ) ;
1336+ let chunk = WithIndices :: new ( chunk. unwrap ( ) ) ;
13591337 data. chunks . push ( chunk) ;
13601338 } ,
13611339 & mut |i, source, source_content| {
0 commit comments