@@ -325,6 +325,7 @@ impl<'a> SourcemapBuilder<'a> {
325325 column_offsets_id : None ,
326326 } ) ;
327327
328+ let mut columns = vec ! [ ] ; // Used as a buffer to reduce memory reallocations.
328329 let remaining = & content. as_bytes ( ) [ line_byte_offset as usize ..] ;
329330 for ( byte_offset_from_line_start, b) in remaining. iter ( ) . enumerate ( ) {
330331 #[ expect( clippy:: cast_possible_truncation) ]
@@ -350,7 +351,7 @@ impl<'a> SourcemapBuilder<'a> {
350351 line. column_offsets_id =
351352 Some ( ColumnOffsetsId :: from_usize ( column_offsets. len ( ) ) ) ;
352353
353- let mut columns = vec ! [ ] ;
354+ columns. clear ( ) ;
354355
355356 // Loop through rest of line char-by-char.
356357 // `chunk_byte_offset` in this loop is byte offset from start of this 1st
@@ -395,7 +396,7 @@ impl<'a> SourcemapBuilder<'a> {
395396 // Record column offsets
396397 column_offsets. push ( ColumnOffsets {
397398 byte_offset_to_first : byte_offset_from_line_start,
398- columns : columns. into_boxed_slice ( ) ,
399+ columns : columns. into_iter ( ) . collect ( ) ,
399400 } ) ;
400401
401402 // Revert back to outer loop for next line
@@ -409,7 +410,7 @@ impl<'a> SourcemapBuilder<'a> {
409410 // Record column offsets
410411 column_offsets. push ( ColumnOffsets {
411412 byte_offset_to_first : byte_offset_from_line_start,
412- columns : columns. into_boxed_slice ( ) ,
413+ columns : columns. into_iter ( ) . collect ( ) ,
413414 } ) ;
414415
415416 break ' lines;
0 commit comments