Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve lexer by make cursor iterate over bytes #915

Merged
merged 12 commits into from
Dec 3, 2020
10 changes: 5 additions & 5 deletions boa/src/syntax/lexer/comment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ impl<R> Tokenizer<R> for SingleLineComment {

// Skip either to the end of the line or to the end of the input
while let Some(ch) = cursor.peek()? {
if ch == '\n' {
if ch == b'\n' {
break;
} else {
// Consume char.
cursor.next_char()?.expect("Comment character vansihed");
cursor.next_byte()?.expect("Comment character vansihed");
}
}
Ok(Token::new(
Expand Down Expand Up @@ -66,10 +66,10 @@ impl<R> Tokenizer<R> for MultiLineComment {

let mut new_line = false;
loop {
if let Some(ch) = cursor.next_char()? {
if ch == '*' && cursor.next_is('/')? {
if let Some(ch) = cursor.next_byte()? {
if ch == b'*' && cursor.next_is(b'/')? {
break;
} else if ch == '\n' {
} else if ch == b'\n' {
new_line = true;
}
} else {
Expand Down