aboutsummaryrefslogtreecommitdiffstats
path: root/src/construct/html_text.rs
diff options
context:
space:
mode:
authorLibravatar Titus Wormer <tituswormer@gmail.com>2022-08-12 19:04:31 +0200
committerLibravatar Titus Wormer <tituswormer@gmail.com>2022-08-12 19:04:31 +0200
commit395b13daf6dd6da0204302d344caa710ea891d62 (patch)
tree4a7c688af7a70c7e3b694d87ba66e01dd0670cf6 /src/construct/html_text.rs
parent6dc2011d69c85820feddf6799142d304cc2eeb29 (diff)
downloadmarkdown-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_text.rs')
-rw-r--r--src/construct/html_text.rs14
1 files changed, 9 insertions, 5 deletions
diff --git a/src/construct/html_text.rs b/src/construct/html_text.rs
index ffbc768..c3b0a65 100644
--- a/src/construct/html_text.rs
+++ b/src/construct/html_text.rs
@@ -666,11 +666,15 @@ pub fn line_ending_before(tokenizer: &mut Tokenizer) -> State {
/// ^
/// ```
pub fn line_ending_after(tokenizer: &mut Tokenizer) -> State {
- tokenizer.attempt(
- State::Next(StateName::HtmlTextLineEndingAfterPrefix),
- State::Next(StateName::HtmlTextLineEndingAfterPrefix),
- );
- State::Retry(space_or_tab(tokenizer))
+ if matches!(tokenizer.current, Some(b'\t' | b' ')) {
+ tokenizer.attempt(
+ State::Next(StateName::HtmlTextLineEndingAfterPrefix),
+ State::Nok,
+ );
+ State::Retry(space_or_tab(tokenizer))
+ } else {
+ State::Retry(StateName::HtmlTextLineEndingAfterPrefix)
+ }
}
/// After eol, after optional whitespace.