Pass a slice instead of a Vec to transcribe.

It avoids some unnecessary allocations.
This commit is contained in:
Nicholas Nethercote 2022-04-11 09:52:34 +10:00
parent 1a7006482e
commit 2657d8f7b3
2 changed files with 3 additions and 3 deletions

View File

@ -263,14 +263,14 @@ fn generic_extension<'cx, 'tt>(
// Ignore the delimiters on the RHS.
let rhs = match &rhses[i] {
mbe::TokenTree::Delimited(_, delimited) => delimited.tts.to_vec(),
mbe::TokenTree::Delimited(_, delimited) => &delimited.tts,
_ => cx.span_bug(sp, "malformed macro rhs"),
};
let arm_span = rhses[i].span();
let rhs_spans = rhs.iter().map(|t| t.span()).collect::<Vec<_>>();
// rhs has holes ( `$id` and `$(...)` that need filled)
let mut tts = match transcribe(cx, &named_matches, rhs, transparency) {
let mut tts = match transcribe(cx, &named_matches, &rhs, transparency) {
Ok(tts) => tts,
Err(mut err) => {
err.emit();

View File

@ -85,7 +85,7 @@ impl<'a> Iterator for Frame<'a> {
pub(super) fn transcribe<'a>(
cx: &ExtCtxt<'a>,
interp: &FxHashMap<MacroRulesNormalizedIdent, NamedMatch>,
src: Vec<mbe::TokenTree>,
src: &[mbe::TokenTree],
transparency: Transparency,
) -> PResult<'a, TokenStream> {
// Nothing for us to transcribe...