mirror of
https://github.com/danbulant/oxc
synced 2026-05-24 12:21:58 +00:00
refactor(parser): remove useless string builder from jsx text lexer (#2096)
relates #2094
This commit is contained in:
parent
8e43eeffe7
commit
3f2b48f1a9
1 changed files with 3 additions and 7 deletions
|
|
@ -952,18 +952,14 @@ impl<'a> Lexer<'a> {
|
||||||
self.current.chars.next();
|
self.current.chars.next();
|
||||||
Kind::LCurly
|
Kind::LCurly
|
||||||
}
|
}
|
||||||
Some(c) => {
|
Some(_) => {
|
||||||
let mut builder = AutoCow::new(self);
|
|
||||||
builder.push_matching(c);
|
|
||||||
loop {
|
loop {
|
||||||
// `>` and `}` are errors in TypeScript but not Babel
|
// `>` and `}` are errors in TypeScript but not Babel
|
||||||
// let's make this less strict so we can parse more code
|
// let's make this less strict so we can parse more code
|
||||||
if matches!(self.peek(), Some('{' | '<')) {
|
if matches!(self.peek(), Some('{' | '<')) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if let Some(c) = self.current.chars.next() {
|
if self.current.chars.next().is_none() {
|
||||||
builder.push_matching(c);
|
|
||||||
} else {
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1369,7 +1365,7 @@ macro_rules! ascii_byte_handler {
|
||||||
const $id: ByteHandler = |$lex| {
|
const $id: ByteHandler = |$lex| {
|
||||||
// SAFETY: This macro is only used for ASCII characters
|
// SAFETY: This macro is only used for ASCII characters
|
||||||
unsafe {
|
unsafe {
|
||||||
use ::assert_unchecked::assert_unchecked;
|
use assert_unchecked::assert_unchecked;
|
||||||
let s = $lex.current.chars.as_str();
|
let s = $lex.current.chars.as_str();
|
||||||
assert_unchecked!(!s.is_empty());
|
assert_unchecked!(!s.is_empty());
|
||||||
assert_unchecked!(s.as_bytes()[0] < 128);
|
assert_unchecked!(s.as_bytes()[0] < 128);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue