Skip to content
Merged
Show file tree
Hide file tree
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
6 changes: 6 additions & 0 deletions .changeset/sweet-pumas-prove.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
swc_core: patch
swc_ecma_parser: patch
---

perf(es/parser): Remove `start` in `State`
2 changes: 1 addition & 1 deletion crates/swc_ecma_parser/src/lexer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1212,7 +1212,7 @@ impl<'a> Lexer<'a> {
}

fn read_int_u32<const RADIX: u8>(&mut self, len: u8) -> LexResult<Option<u32>> {
let start = self.state().start();
let start = self.cur_pos();

let mut count = 0;
let v = self.read_digits::<_, Option<u32>, RADIX>(
Expand Down
17 changes: 0 additions & 17 deletions crates/swc_ecma_parser/src/lexer/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ pub struct State {
/// TODO: Remove this field.
is_first: bool,
pub next_regexp: Option<BytePos>,
pub start: BytePos,
pub prev_hi: BytePos,

pub(super) token_value: Option<TokenValue>,
Expand Down Expand Up @@ -392,14 +391,6 @@ impl Lexer<'_> {
return Ok(Token::Eof);
}

// println!(
// "\tContext: ({:?}) {:?}",
// self.input.cur().unwrap(),
// self.state.context.0
// );

self.state.start = *start;

self.read_token()
}

Expand Down Expand Up @@ -499,8 +490,6 @@ impl Lexer<'_> {
value: value.into(),
});

self.state.start = start;

Ok(Token::JSXText)
}

Expand Down Expand Up @@ -587,7 +576,6 @@ impl State {
had_line_break: false,
is_first: true,
next_regexp: None,
start: BytePos(0),
prev_hi: start_pos,
token_value: None,
token_type: None,
Expand Down Expand Up @@ -625,11 +613,6 @@ impl State {
self.prev_hi
}

#[inline(always)]
pub fn start(&self) -> BytePos {
self.start
}

pub fn can_have_trailing_line_comment(&self) -> bool {
let Some(t) = self.token_type() else {
return true;
Expand Down
Loading