diff options
author | Titus Wormer <tituswormer@gmail.com> | 2022-08-12 19:04:31 +0200 |
---|---|---|
committer | Titus Wormer <tituswormer@gmail.com> | 2022-08-12 19:04:31 +0200 |
commit | 395b13daf6dd6da0204302d344caa710ea891d62 (patch) | |
tree | 4a7c688af7a70c7e3b694d87ba66e01dd0670cf6 /src/construct/html_flow.rs | |
parent | 6dc2011d69c85820feddf6799142d304cc2eeb29 (diff) | |
download | markdown-rs-395b13daf6dd6da0204302d344caa710ea891d62.tar.gz markdown-rs-395b13daf6dd6da0204302d344caa710ea891d62.tar.bz2 markdown-rs-395b13daf6dd6da0204302d344caa710ea891d62.zip |
Refactor to attempt less if never needed
Diffstat (limited to 'src/construct/html_flow.rs')
-rw-r--r-- | src/construct/html_flow.rs | 33 |
1 files changed, 19 insertions, 14 deletions
diff --git a/src/construct/html_flow.rs b/src/construct/html_flow.rs index 123e1a3..e90abc4 100644 --- a/src/construct/html_flow.rs +++ b/src/construct/html_flow.rs @@ -133,21 +133,26 @@ const COMPLETE: u8 = 7; pub fn start(tokenizer: &mut Tokenizer) -> State { if tokenizer.parse_state.constructs.html_flow { tokenizer.enter(Name::HtmlFlow); - tokenizer.attempt(State::Next(StateName::HtmlFlowBefore), State::Nok); - State::Retry(space_or_tab_with_options( - tokenizer, - SpaceOrTabOptions { - kind: Name::HtmlFlowData, - min: 0, - max: if tokenizer.parse_state.constructs.code_indented { - TAB_SIZE - 1 - } else { - usize::MAX + + if matches!(tokenizer.current, Some(b'\t' | b' ')) { + tokenizer.attempt(State::Next(StateName::HtmlFlowBefore), State::Nok); + State::Retry(space_or_tab_with_options( + tokenizer, + SpaceOrTabOptions { + kind: Name::HtmlFlowData, + min: 0, + max: if tokenizer.parse_state.constructs.code_indented { + TAB_SIZE - 1 + } else { + usize::MAX + }, + connect: false, + content: None, }, - connect: false, - content: None, - }, - )) + )) + } else { + State::Retry(StateName::HtmlFlowBefore) + } } else { State::Nok } |