mirror of
https://github.com/danbulant/oxc
synced 2026-05-19 12:19:15 +00:00
perf(parser): faster decoding unicode escapes in identifiers (#4579)
Replace `next_char` and `peek_char` with `peek_byte` when decoding unicode escape sequences in identifiers.
This commit is contained in:
parent
ae1d38f60d
commit
55a8763d6e
1 changed files with 6 additions and 3 deletions
|
|
@ -54,14 +54,17 @@ impl<'a> Lexer<'a> {
|
|||
check_identifier_start: bool,
|
||||
) {
|
||||
let start = self.offset();
|
||||
if self.next_char() != Some('u') {
|
||||
if self.peek_byte() == Some(b'u') {
|
||||
self.consume_char();
|
||||
} else {
|
||||
self.next_char();
|
||||
let range = Span::new(start, self.offset());
|
||||
self.error(diagnostics::unicode_escape_sequence(range));
|
||||
return;
|
||||
}
|
||||
|
||||
let value = match self.peek_char() {
|
||||
Some('{') => self.unicode_code_point(),
|
||||
let value = match self.peek_byte() {
|
||||
Some(b'{') => self.unicode_code_point(),
|
||||
_ => self.surrogate_pair(),
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue