diff options
| author | Vadim Petrochenkov <vadim.petrochenkov@gmail.com> | 2024-03-03 15:34:22 +0300 |
|---|---|---|
| committer | Vadim Petrochenkov <vadim.petrochenkov@gmail.com> | 2024-06-10 02:20:16 +0300 |
| commit | d5dd2d8284c30f3f79e4beb35246761ed4892c49 (patch) | |
| tree | ae670bd652137dd07dfca5d548aad3697e50c7dc /compiler/rustc_expand/src/mbe | |
| parent | a70b2ae57713ed0e7411c059d582ab382fc4166a (diff) | |
| download | rust-d5dd2d8284c30f3f79e4beb35246761ed4892c49.tar.gz rust-d5dd2d8284c30f3f79e4beb35246761ed4892c49.zip | |
rustc_span: Optimize syntax context updates in spans
Diffstat (limited to 'compiler/rustc_expand/src/mbe')
| -rw-r--r-- | compiler/rustc_expand/src/mbe/transcribe.rs | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/compiler/rustc_expand/src/mbe/transcribe.rs b/compiler/rustc_expand/src/mbe/transcribe.rs index 3196b826085..25e961d6009 100644 --- a/compiler/rustc_expand/src/mbe/transcribe.rs +++ b/compiler/rustc_expand/src/mbe/transcribe.rs @@ -30,11 +30,11 @@ impl MutVisitor for Marker { // it's some advanced case with macro-generated macros. So if we cache the marked version // of that context once, we'll typically have a 100% cache hit rate after that. let Marker(expn_id, transparency, ref mut cache) = *self; - let data = span.data(); - let marked_ctxt = *cache - .entry(data.ctxt) - .or_insert_with(|| data.ctxt.apply_mark(expn_id.to_expn_id(), transparency)); - *span = data.with_ctxt(marked_ctxt); + span.update_ctxt(|ctxt| { + *cache + .entry(ctxt) + .or_insert_with(|| ctxt.apply_mark(expn_id.to_expn_id(), transparency)) + }); } } |
