mirror of
https://github.com/danbulant/oxc
synced 2026-05-19 04:08:41 +00:00
refactor(parser): convert Lexer::read_minus to a single match (#4574)
Same as #4573. Convert `Lexer::read_minus` to a single match rather than multiple `next_ascii_byte_eq` calls.
This commit is contained in:
parent
ef5418a917
commit
bba824bc34
1 changed files with 16 additions and 13 deletions
|
|
@ -38,20 +38,23 @@ impl<'a> Lexer<'a> {
|
|||
|
||||
/// returns None for `SingleLineHTMLCloseComment` `-->` in script mode
|
||||
pub(super) fn read_minus(&mut self) -> Option<Kind> {
|
||||
if self.next_ascii_byte_eq(b'-') {
|
||||
// SingleLineHTMLCloseComment `-->` in script mode
|
||||
if self.token.is_on_new_line
|
||||
&& self.source_type.is_script()
|
||||
&& self.next_ascii_byte_eq(b'>')
|
||||
{
|
||||
None
|
||||
} else {
|
||||
Some(Kind::Minus2)
|
||||
match self.peek_byte() {
|
||||
Some(b'-') => {
|
||||
self.consume_char();
|
||||
if self.token.is_on_new_line
|
||||
&& self.source_type.is_script()
|
||||
&& self.next_ascii_byte_eq(b'>')
|
||||
{
|
||||
None
|
||||
} else {
|
||||
Some(Kind::Minus2)
|
||||
}
|
||||
}
|
||||
} else if self.next_ascii_byte_eq(b'=') {
|
||||
Some(Kind::MinusEq)
|
||||
} else {
|
||||
Some(Kind::Minus)
|
||||
Some(b'=') => {
|
||||
self.consume_char();
|
||||
Some(Kind::MinusEq)
|
||||
}
|
||||
_ => Some(Kind::Minus),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue