mirror of
https://github.com/danbulant/oxc
synced 2026-05-25 12:51:57 +00:00
refactor(parser): remove unsafe code in lexer (#2549)
Same as #2527. Just remove some unnecessary unsafe code, no substantive changes.
This commit is contained in:
parent
1391e4a86b
commit
ddccaa1af9
1 changed files with 4 additions and 5 deletions
|
|
@ -112,7 +112,7 @@ macro_rules! handle_string_literal_escape {
|
||||||
// `Source`'s invariant temporarily, but the guarantees of `SafeByteMatchTable`
|
// `Source`'s invariant temporarily, but the guarantees of `SafeByteMatchTable`
|
||||||
// mean `!table.matches(b)` on this branch prevents exiting this loop until
|
// mean `!table.matches(b)` on this branch prevents exiting this loop until
|
||||||
// `source` is positioned on a UTF-8 character boundary again.
|
// `source` is positioned on a UTF-8 character boundary again.
|
||||||
unsafe { $lexer.source.next_byte_unchecked() };
|
$lexer.source.next_byte_unchecked();
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
b if b == $delimiter => {
|
b if b == $delimiter => {
|
||||||
|
|
@ -132,16 +132,15 @@ macro_rules! handle_string_literal_escape {
|
||||||
str.push_str(chunk);
|
str.push_str(chunk);
|
||||||
continue 'outer;
|
continue 'outer;
|
||||||
}
|
}
|
||||||
b'\r' | b'\n' => {
|
_ => {
|
||||||
// This is impossible in valid JS, so cold path
|
// Line break. This is impossible in valid JS, so cold path.
|
||||||
return cold_branch(|| {
|
return cold_branch(|| {
|
||||||
|
debug_assert!(matches!(b, b'\r' | b'\n'));
|
||||||
$lexer.consume_char();
|
$lexer.consume_char();
|
||||||
$lexer.error(diagnostics::UnterminatedString($lexer.unterminated_range()));
|
$lexer.error(diagnostics::UnterminatedString($lexer.unterminated_range()));
|
||||||
Kind::Undetermined
|
Kind::Undetermined
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
// SAFETY: Caller guarantees `table` does not match any other bytes
|
|
||||||
_ => assert_unchecked::unreachable_unchecked!(),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue