diff options
author | Titus Wormer <tituswormer@gmail.com> | 2022-07-25 15:29:11 +0200 |
---|---|---|
committer | Titus Wormer <tituswormer@gmail.com> | 2022-07-25 15:29:11 +0200 |
commit | 11304728b6607bc2a8d41a640308f3379a25b933 (patch) | |
tree | c49fb64a64e1c39b889a40f48dcd44f87aaea7b1 /src/subtokenize.rs | |
parent | 9c18ff7858730f0c7782206129375c7efcb7d77f (diff) | |
download | markdown-rs-11304728b6607bc2a8d41a640308f3379a25b933.tar.gz markdown-rs-11304728b6607bc2a8d41a640308f3379a25b933.tar.bz2 markdown-rs-11304728b6607bc2a8d41a640308f3379a25b933.zip |
Improve performance w/ a single feed loop
Diffstat (limited to 'src/subtokenize.rs')
-rw-r--r-- | src/subtokenize.rs | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/subtokenize.rs b/src/subtokenize.rs index 2b5d775..0c9df34 100644 --- a/src/subtokenize.rs +++ b/src/subtokenize.rs @@ -84,6 +84,7 @@ 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 { @@ -96,7 +97,7 @@ pub fn subtokenize(events: &mut Vec<Event>, parse_state: &ParseState) -> bool { }; if link_curr.previous != None { - tokenizer.define_skip(&enter.point); + tokenizer.define_skip(&enter.point, size); } let func = match state { @@ -105,10 +106,13 @@ pub fn subtokenize(events: &mut Vec<Event>, parse_state: &ParseState) -> bool { }; state = tokenizer.push( - span::codes(&parse_state.codes, &span), + span::codes(&parse_state.codes, &span).to_vec(), func, link_curr.next == None, ); + + size += span.end_index - span.start_index; + link_index = link_curr.next; } |