mirror of
https://github.com/rust-lang/rust.git
synced 2025-02-27 22:34:14 +00:00
Pass a slice instead of a Vec
to transcribe
.
It avoids some unnecessary allocations.
This commit is contained in:
parent
1a7006482e
commit
2657d8f7b3
@ -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();
|
||||
|
@ -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...
|
||||
|
Loading…
Reference in New Issue
Block a user