diff options
author | Titus Wormer <tituswormer@gmail.com> | 2022-07-25 15:52:35 +0200 |
---|---|---|
committer | Titus Wormer <tituswormer@gmail.com> | 2022-07-25 15:52:35 +0200 |
commit | ca56f2742d8719358d2046fbdee4f1087add0568 (patch) | |
tree | 702d3ff3ab6ad432bdff59990b7b4211da57afda /src/subtokenize.rs | |
parent | 11304728b6607bc2a8d41a640308f3379a25b933 (diff) | |
download | markdown-rs-ca56f2742d8719358d2046fbdee4f1087add0568.tar.gz markdown-rs-ca56f2742d8719358d2046fbdee4f1087add0568.tar.bz2 markdown-rs-ca56f2742d8719358d2046fbdee4f1087add0568.zip |
Refactor to remove need for cloning codes
Diffstat (limited to 'src/subtokenize.rs')
-rw-r--r-- | src/subtokenize.rs | 14 |
1 files changed, 4 insertions, 10 deletions
diff --git a/src/subtokenize.rs b/src/subtokenize.rs index 0c9df34..a1ec90a 100644 --- a/src/subtokenize.rs +++ b/src/subtokenize.rs @@ -24,7 +24,7 @@ use crate::content::{string::start as string, text::start as text}; use crate::parser::ParseState; use crate::tokenizer::{ContentType, Event, EventType, State, Tokenizer}; -use crate::util::{edit_map::EditMap, span}; +use crate::util::edit_map::EditMap; /// Create a link between two [`Event`][]s. /// @@ -84,20 +84,15 @@ pub fn subtokenize(events: &mut Vec<Event>, parse_state: &ParseState) -> bool { } else { text })); - let mut size = 0; // Loop through links to pass them in order to the subtokenizer. while let Some(index) = link_index { let enter = &events[index]; let link_curr = enter.link.as_ref().expect("expected link"); assert_eq!(enter.event_type, EventType::Enter); - let span = span::Span { - start_index: enter.point.index, - end_index: events[index + 1].point.index, - }; if link_curr.previous != None { - tokenizer.define_skip(&enter.point, size); + tokenizer.define_skip(&enter.point); } let func = match state { @@ -106,13 +101,12 @@ pub fn subtokenize(events: &mut Vec<Event>, parse_state: &ParseState) -> bool { }; state = tokenizer.push( - span::codes(&parse_state.codes, &span).to_vec(), + enter.point.index, + events[index + 1].point.index, func, link_curr.next == None, ); - size += span.end_index - span.start_index; - link_index = link_curr.next; } |