Skip to content

Commit 7b5bcd7

Browse files
authored
perf(es/parser): Remove had_line_break_before_last (#11200)
**Description:** I find that this property is only written, not read.
1 parent acca984 commit 7b5bcd7

File tree

2 files changed

+6
-7
lines changed

2 files changed

+6
-7
lines changed

.changeset/brave-penguins-shake.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
swc_core: patch
3+
swc_ecma_parser: patch
4+
---
5+
6+
perf(es/parser): Remove `had_line_break_before_last`

crates/swc_ecma_parser/src/lexer/state.rs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,6 @@ bitflags::bitflags! {
3131
pub struct State {
3232
/// if line break exists between previous token and new token?
3333
pub had_line_break: bool,
34-
/// if line break exists before last?
35-
pub had_line_break_before_last: bool,
3634
/// TODO: Remove this field.
3735
is_first: bool,
3836
pub next_regexp: Option<BytePos>,
@@ -204,7 +202,6 @@ impl crate::input::Tokens for Lexer<'_> {
204202

205203
self.state.set_token_type(token);
206204
self.state.prev_hi = self.last_pos();
207-
self.state.had_line_break_before_last = self.had_line_break_before_last();
208205
}
209206
// Attach span to token.
210207
TokenAndSpan {
@@ -236,7 +233,6 @@ impl crate::input::Tokens for Lexer<'_> {
236233

237234
self.state.set_token_type(token);
238235
self.state.prev_hi = self.last_pos();
239-
self.state.had_line_break_before_last = self.had_line_break_before_last();
240236
}
241237
// Attach span to token.
242238
TokenAndSpan {
@@ -360,7 +356,6 @@ impl crate::input::Tokens for Lexer<'_> {
360356

361357
self.state.set_token_type(token);
362358
self.state.prev_hi = self.last_pos();
363-
self.state.had_line_break_before_last = self.had_line_break_before_last();
364359
}
365360
// Attach span to token.
366361
TokenAndSpan {
@@ -574,7 +569,6 @@ impl Iterator for Lexer<'_> {
574569

575570
self.state.set_token_type(token);
576571
self.state.prev_hi = self.last_pos();
577-
self.state.had_line_break_before_last = self.had_line_break_before_last();
578572
// Attach span to token.
579573
Some(TokenAndSpan {
580574
token,
@@ -591,7 +585,6 @@ impl State {
591585
pub fn new(start_pos: BytePos) -> Self {
592586
State {
593587
had_line_break: false,
594-
had_line_break_before_last: false,
595588
is_first: true,
596589
next_regexp: None,
597590
start: BytePos(0),

0 commit comments

Comments
 (0)