aboutsummaryrefslogtreecommitdiff
path: root/src/tokenizer/machine.rs
diff options
context:
space:
mode:
authorMartin Fischer <martin@push-f.com>2023-09-15 08:34:55 +0200
committerMartin Fischer <martin@push-f.com>2023-09-28 10:36:08 +0200
commit01661b3a5060cde9b44ae2543e1186139d99bdd3 (patch)
tree830eb4ce75be433c439fae29768acbfdb26f57a0 /src/tokenizer/machine.rs
parent301e8ab009a48c7f44547cbb2242fdf280f04438 (diff)
refactor: remove needless match & map
Diffstat (limited to 'src/tokenizer/machine.rs')
-rw-r--r--src/tokenizer/machine.rs16
1 files changed, 6 insertions, 10 deletions
diff --git a/src/tokenizer/machine.rs b/src/tokenizer/machine.rs
index 28b101d..b6291b5 100644
--- a/src/tokenizer/machine.rs
+++ b/src/tokenizer/machine.rs
@@ -1799,17 +1799,13 @@ where
}
}
State::NamedCharacterReference => {
- let first_char = slf.read_char()?;
+ let first_char = slf.read_char()?.unwrap(); // unwrap cannot panic since we just unread the char
- let char_ref = match first_char {
- Some(x) => try_read_character_reference(x, |x| slf.try_read_string(x, true))?
- .map(|char_ref| (x, char_ref)),
+ let char_ref =
+ try_read_character_reference(first_char, |x| slf.try_read_string(x, true))?;
- None => None,
- };
-
- if let Some((x, char_ref)) = char_ref {
- slf.temporary_buffer.push(x);
+ if let Some(char_ref) = char_ref {
+ slf.temporary_buffer.push(first_char);
slf.temporary_buffer.push_str(char_ref.name);
let char_ref_name_last_character = char_ref.name.chars().last();
@@ -1835,7 +1831,7 @@ where
Ok(ControlToken::Continue)
}
} else {
- slf.unread_char(first_char);
+ slf.unread_char(Some(first_char));
slf.flush_code_points_consumed_as_character_reference();
slf.state = State::AmbiguousAmpersand;
Ok(ControlToken::Continue)