diff options
| author | Nicholas Nethercote <n.nethercote@gmail.com> | 2022-04-20 16:34:33 +1000 |
|---|---|---|
| committer | Nicholas Nethercote <n.nethercote@gmail.com> | 2022-04-21 09:21:45 +1000 |
| commit | 7a89255b20d6fcbaf96ceeddcf6de119ee4ae0a5 (patch) | |
| tree | 7e856f5492ce59713dd077029a37bba82e2496c4 /compiler/rustc_parse | |
| parent | 880318c70a3cf676acae9c1e61ac6519f7f67f46 (diff) | |
| download | rust-7a89255b20d6fcbaf96ceeddcf6de119ee4ae0a5.tar.gz rust-7a89255b20d6fcbaf96ceeddcf6de119ee4ae0a5.zip | |
Avoid some tuple destructuring.
Surprisingly, this is a non-trivial performance win.
Diffstat (limited to 'compiler/rustc_parse')
| -rw-r--r-- | compiler/rustc_parse/src/parser/mod.rs | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/compiler/rustc_parse/src/parser/mod.rs b/compiler/rustc_parse/src/parser/mod.rs index 581d706f682..450bdb510a5 100644 --- a/compiler/rustc_parse/src/parser/mod.rs +++ b/compiler/rustc_parse/src/parser/mod.rs @@ -994,22 +994,24 @@ impl<'a> Parser<'a> { /// Advance the parser by one token. pub fn bump(&mut self) { - let (mut next, spacing) = self.token_cursor.inlined_next(self.desugar_doc_comments); + // Note: destructuring here would give nicer code, but it was found in #96210 to be slower + // than `.0`/`.1` access. + let mut next = self.token_cursor.inlined_next(self.desugar_doc_comments); self.token_cursor.num_next_calls += 1; // We've retrieved an token from the underlying // cursor, so we no longer need to worry about // an unglued token. See `break_and_eat` for more details self.token_cursor.break_last_token = false; - if next.span.is_dummy() { + if next.0.span.is_dummy() { // Tweak the location for better diagnostics, but keep syntactic context intact. let fallback_span = self.token.span; - next.span = fallback_span.with_ctxt(next.span.ctxt()); + next.0.span = fallback_span.with_ctxt(next.0.span.ctxt()); } debug_assert!(!matches!( - next.kind, + next.0.kind, token::OpenDelim(token::NoDelim) | token::CloseDelim(token::NoDelim) )); - self.inlined_bump_with((next, spacing)) + self.inlined_bump_with(next) } /// Look-ahead `dist` tokens of `self.token` and get access to that token there. |
