From 6ba11bdaca1721fb4591819604c340d147798f45 Mon Sep 17 00:00:00 2001 From: Titus Wormer Date: Fri, 12 Aug 2022 17:02:01 +0200 Subject: Remove `match` statements if clumsy --- src/construct/label_start_link.rs | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) (limited to 'src/construct/label_start_link.rs') diff --git a/src/construct/label_start_link.rs b/src/construct/label_start_link.rs index 7288d5d..8089e80 100644 --- a/src/construct/label_start_link.rs +++ b/src/construct/label_start_link.rs @@ -39,21 +39,20 @@ use crate::tokenizer::{LabelStart, Tokenizer}; /// ^ /// ``` pub fn start(tokenizer: &mut Tokenizer) -> State { - match tokenizer.current { - Some(b'[') if tokenizer.parse_state.constructs.label_start_link => { - let start = tokenizer.events.len(); - tokenizer.enter(Name::LabelLink); - tokenizer.enter(Name::LabelMarker); - tokenizer.consume(); - tokenizer.exit(Name::LabelMarker); - tokenizer.exit(Name::LabelLink); - tokenizer.tokenize_state.label_start_stack.push(LabelStart { - start: (start, tokenizer.events.len() - 1), - inactive: false, - }); - tokenizer.register_resolver_before(ResolveName::Label); - State::Ok - } - _ => State::Nok, + if tokenizer.parse_state.constructs.label_start_link && tokenizer.current == Some(b'[') { + let start = tokenizer.events.len(); + tokenizer.enter(Name::LabelLink); + tokenizer.enter(Name::LabelMarker); + tokenizer.consume(); + tokenizer.exit(Name::LabelMarker); + tokenizer.exit(Name::LabelLink); + tokenizer.tokenize_state.label_start_stack.push(LabelStart { + start: (start, tokenizer.events.len() - 1), + inactive: false, + }); + tokenizer.register_resolver_before(ResolveName::Label); + State::Ok + } else { + State::Nok } } -- cgit