Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions crates/oxc_parser/src/lexer/source.rs
Original file line number Diff line number Diff line change
Expand Up @@ -438,11 +438,12 @@ impl<'a> Source<'a> {
#[allow(dead_code)]
#[inline]
unsafe fn next_byte(&mut self) -> Option<u8> {
if self.is_eof() {
None
} else {
#[allow(clippy::if_not_else)] // Hot path first
if !self.is_eof() {
// SAFETY: Safe to read from `ptr` as we just checked it's not out of bounds
Some(self.next_byte_unchecked())
} else {
None
}
}

Expand Down Expand Up @@ -503,11 +504,12 @@ impl<'a> Source<'a> {
/// Peek next byte of source without consuming it.
#[inline]
pub(super) fn peek_byte(&self) -> Option<u8> {
if self.is_eof() {
None
} else {
#[allow(clippy::if_not_else)] // Hot path first
if !self.is_eof() {
// SAFETY: Safe to read from `ptr` as we just checked it's not out of bounds
Some(unsafe { self.peek_byte_unchecked() })
} else {
None
}
}

Expand Down