@@ -74,6 +74,11 @@ impl ParseResult {
7474 bufs. concat ( )
7575 }
7676}
77+
78+ /// stupid helper function, used because Rust doesn't currently let you collect into an array
79+ fn line_indices ( idx : usize ) -> [ usize ; 6 ] {
80+ [ idx, idx + 1 , idx + 2 , idx + 3 , idx + 4 , idx + 5 ]
81+ }
7782pub fn parse < L : ParseLines > ( lines : & L ) -> ParseResult {
7883 let mut r = ParseResult :: new ( ) ;
7984 let mut part_first_line = 0 ;
@@ -94,7 +99,7 @@ pub fn parse<L: ParseLines>(lines: &L) -> ParseResult {
9499 let _part = span ! ( Level :: DEBUG , "parsing part" , ?range) ;
95100 let _part = _part. enter ( ) ;
96101 r. offsets . push ( ( part_first_line as u32 , r. tick_stream . len ( ) as u32 ) ) ;
97- let mut part: Vec < & str > = range . map ( |s| lines. get_line ( s) . trim ( ) ) . collect ( ) ; // TODO: check if this is slow
102+ let mut part: [ & str ; 6 ] = line_indices ( part_first_line ) . map ( |s| lines. get_line ( s) . trim ( ) ) ; // TODO: check if this is slow
98103
99104 // The current tick in THIS PART
100105 let mut tick = 0 ;
@@ -311,7 +316,7 @@ pub fn source_location_from_stream(r: &ParseResult, tick_location: u32) -> (u32,
311316 ( actual_line, offset_on_line)
312317}
313318
314- pub fn dump_source ( input : & Vec < & str > ) -> String {
319+ pub fn dump_source ( input : & [ & str ] ) -> String {
315320 use itertools:: Itertools ;
316321 std:: iter:: once ( & "" ) . chain ( input. iter ( ) ) . join ( "\n " )
317322}
0 commit comments