Skip to content

Commit 2657d8f

Browse files
committed
Pass a slice instead of a Vec to transcribe.
It avoids some unnecessary allocations.
1 parent 1a70064 commit 2657d8f

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

compiler/rustc_expand/src/mbe/macro_rules.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -263,14 +263,14 @@ fn generic_extension<'cx, 'tt>(
263263

264264
// Ignore the delimiters on the RHS.
265265
let rhs = match &rhses[i] {
266-
mbe::TokenTree::Delimited(_, delimited) => delimited.tts.to_vec(),
266+
mbe::TokenTree::Delimited(_, delimited) => &delimited.tts,
267267
_ => cx.span_bug(sp, "malformed macro rhs"),
268268
};
269269
let arm_span = rhses[i].span();
270270

271271
let rhs_spans = rhs.iter().map(|t| t.span()).collect::<Vec<_>>();
272272
// rhs has holes ( `$id` and `$(...)` that need filled)
273-
let mut tts = match transcribe(cx, &named_matches, rhs, transparency) {
273+
let mut tts = match transcribe(cx, &named_matches, &rhs, transparency) {
274274
Ok(tts) => tts,
275275
Err(mut err) => {
276276
err.emit();

compiler/rustc_expand/src/mbe/transcribe.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ impl<'a> Iterator for Frame<'a> {
8585
pub(super) fn transcribe<'a>(
8686
cx: &ExtCtxt<'a>,
8787
interp: &FxHashMap<MacroRulesNormalizedIdent, NamedMatch>,
88-
src: Vec<mbe::TokenTree>,
88+
src: &[mbe::TokenTree],
8989
transparency: Transparency,
9090
) -> PResult<'a, TokenStream> {
9191
// Nothing for us to transcribe...

0 commit comments

Comments
 (0)