@@ -7,7 +7,7 @@ use super::{
77use crate :: {
88 backend:: errors:: backend_error:: BackendError , parser:: tab_element:: TabElementError , ParseLines ,
99} ;
10- use std:: ops:: RangeInclusive ;
10+ use std:: { array , ops:: RangeInclusive } ;
1111
1212pub fn line_is_valid ( line : & str ) -> bool {
1313 let line = line. trim ( ) ;
@@ -74,6 +74,7 @@ impl ParseResult {
7474 bufs. concat ( )
7575 }
7676}
77+
7778pub fn parse < L : ParseLines > ( lines : & L ) -> ParseResult {
7879 let mut r = ParseResult :: new ( ) ;
7980 let mut part_first_line = 0 ;
@@ -94,7 +95,8 @@ pub fn parse<L: ParseLines>(lines: &L) -> ParseResult {
9495 let _part = span ! ( Level :: DEBUG , "parsing part" , ?range) ;
9596 let _part = _part. enter ( ) ;
9697 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
98+ let mut part: [ & str ; 6 ] =
99+ array:: from_fn ( |i| part_first_line + i) . map ( |s| lines. get_line ( s) . trim ( ) ) ; // TODO: check if this is slow
98100
99101 // The current tick in THIS PART
100102 let mut tick = 0 ;
@@ -311,7 +313,7 @@ pub fn source_location_from_stream(r: &ParseResult, tick_location: u32) -> (u32,
311313 ( actual_line, offset_on_line)
312314}
313315
314- pub fn dump_source ( input : & Vec < & str > ) -> String {
316+ pub fn dump_source ( input : & [ & str ] ) -> String {
315317 use itertools:: Itertools ;
316318 std:: iter:: once ( & "" ) . chain ( input. iter ( ) ) . join ( "\n " )
317319}
0 commit comments