Don't unnecessarily clone the input tt for decl macros

This commit is contained in:
Lukas Wirth 2023-07-10 16:28:23 +02:00
parent d5f64f875a
commit f6c09099da
3 changed files with 23 additions and 12 deletions

View file

@ -38,7 +38,7 @@ fn benchmark_expand_macro_rules() {
invocations
.into_iter()
.map(|(id, tt)| {
let res = rules[&id].expand(&tt);
let res = rules[&id].expand(tt);
assert!(res.err.is_none());
res.value.token_trees.len()
})
@ -102,7 +102,7 @@ fn invocation_fixtures(rules: &FxHashMap<String, DeclarativeMacro>) -> Vec<(Stri
for op in rule.lhs.iter() {
collect_from_op(op, &mut subtree, &mut seed);
}
if it.expand(&subtree).err.is_none() {
if it.expand(subtree.clone()).err.is_none() {
res.push((name.clone(), subtree));
break;
}