diff options
author | Titus Wormer <tituswormer@gmail.com> | 2022-07-20 12:34:06 +0200 |
---|---|---|
committer | Titus Wormer <tituswormer@gmail.com> | 2022-07-20 12:34:06 +0200 |
commit | 7894ec75a7070591c3499fce1f409563c4edc7d7 (patch) | |
tree | 170d736268a30b728f28b164213a0a0ac47414da /src/content/document.rs | |
parent | 7ec35068c86a546dac8172e74e8a34e3b6813eb2 (diff) | |
download | markdown-rs-7894ec75a7070591c3499fce1f409563c4edc7d7.tar.gz markdown-rs-7894ec75a7070591c3499fce1f409563c4edc7d7.tar.bz2 markdown-rs-7894ec75a7070591c3499fce1f409563c4edc7d7.zip |
Refactor to use less vecs for events
Diffstat (limited to '')
-rw-r--r-- | src/content/document.rs | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/src/content/document.rs b/src/content/document.rs index 53e58c4..d35060c 100644 --- a/src/content/document.rs +++ b/src/content/document.rs @@ -106,15 +106,16 @@ pub fn document(parse_state: &mut ParseState, point: Point, index: usize) -> Vec index += 1; } - let mut result = (tokenizer.events, false); + let mut done = false; + let mut events = tokenizer.events; parse_state.definitions = next_definitions; - while !result.1 { - result = subtokenize(result.0, parse_state); + while !done { + done = subtokenize(&mut events, parse_state); } - result.0 + events } /// Before document. @@ -415,7 +416,7 @@ fn flow_end( info = exit_containers(tokenizer, info, &Phase::Eof); } - tokenizer.events = resolve(tokenizer, &info); + resolve(tokenizer, &info); (State::Ok, Some(vec![code])) } @@ -481,7 +482,7 @@ fn exit_containers( } // Inject the container events. -fn resolve(tokenizer: &mut Tokenizer, info: &DocumentInfo) -> Vec<Event> { +fn resolve(tokenizer: &mut Tokenizer, info: &DocumentInfo) { let mut map = EditMap::new(); let mut line_index = 0; let mut index = 0; @@ -537,5 +538,5 @@ fn resolve(tokenizer: &mut Tokenizer, info: &DocumentInfo) -> Vec<Event> { add, ); - map.consume(tokenizer.events.split_off(0)) + map.consume(&mut tokenizer.events); } |