From 2f21280db96e9c8086e123f756f5cad27cbfa0bf Mon Sep 17 00:00:00 2001 From: Titus Wormer Date: Thu, 13 Oct 2022 18:14:23 +0200 Subject: Refactor some code to improve coverage --- src/parser.rs | 32 +++++++++++++------------------- 1 file changed, 13 insertions(+), 19 deletions(-) (limited to 'src/parser.rs') diff --git a/src/parser.rs b/src/parser.rs index a7962d0..4e8d859 100644 --- a/src/parser.rs +++ b/src/parser.rs @@ -47,15 +47,13 @@ pub fn parse<'a>( gfm_footnote_definitions: vec![], }; - let mut tokenizer = Tokenizer::new( - Point { - line: 1, - column: 1, - index: 0, - vs: 0, - }, - &parse_state, - ); + let start = Point { + line: 1, + column: 1, + index: 0, + vs: 0, + }; + let mut tokenizer = Tokenizer::new(start, &parse_state); let state = tokenizer.push( (0, 0), @@ -65,21 +63,17 @@ pub fn parse<'a>( let mut result = tokenizer.flush(state, true)?; let mut events = tokenizer.events; - parse_state - .gfm_footnote_definitions - .append(&mut result.gfm_footnote_definitions); - parse_state.definitions.append(&mut result.definitions); - loop { - let mut result = subtokenize(&mut events, &parse_state, &None)?; - parse_state - .gfm_footnote_definitions - .append(&mut result.gfm_footnote_definitions); - parse_state.definitions.append(&mut result.definitions); + let fn_defs = &mut parse_state.gfm_footnote_definitions; + let defs = &mut parse_state.definitions; + fn_defs.append(&mut result.gfm_footnote_definitions); + defs.append(&mut result.definitions); if result.done { break; } + + result = subtokenize(&mut events, &parse_state, &None)?; } Ok((events, parse_state)) -- cgit