Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

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/flat-humans-sneeze.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
swc_core: patch
swc_common: patch
---

pref(es/common): use next rather than nth
11 changes: 9 additions & 2 deletions crates/swc_common/src/input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,19 @@ impl Input for StringInput<'_> {

#[inline]
fn peek(&mut self) -> Option<char> {
self.iter.clone().nth(1)
let mut iter = self.iter.clone();
// https://github.com/rust-lang/rust/blob/1.86.0/compiler/rustc_lexer/src/cursor.rs#L56 say `next` is faster.
iter.next();
iter.next()
}

#[inline]
fn peek_ahead(&mut self) -> Option<char> {
self.iter.clone().nth(2)
let mut iter = self.iter.clone();
// https://github.com/rust-lang/rust/blob/1.86.0/compiler/rustc_lexer/src/cursor.rs#L56 say `next` is faster
iter.next();
iter.next();
iter.next()
}

#[inline]
Expand Down
Loading