]> git.lizzy.rs Git - rust.git/commit
Split `NamedMatch::MatchNonterminal` in two.
authorNicholas Nethercote <n.nethercote@gmail.com>
Wed, 23 Mar 2022 00:46:22 +0000 (11:46 +1100)
committerNicholas Nethercote <n.nethercote@gmail.com>
Fri, 25 Mar 2022 01:35:52 +0000 (12:35 +1100)
commit6817442ec7d9f29abfb080314f3c45ff5e3e633a
treede02bcbb8b9359321f7bce1a99f9db92ef1376dc
parent904e70a7b00f41b168add13a33bc14f200442ad0
Split `NamedMatch::MatchNonterminal` in two.

The `Lrc` is only relevant within `transcribe()`. There, the `Lrc` is
helpful for the non-`NtTT` cases, because the entire nonterminal is
cloned. But for the `NtTT` cases the inner token tree is cloned (a full
clone) and so the `Lrc` is of no help.

This commit splits the `NtTT` and non-`NtTT` cases, avoiding the useless
`Lrc` in the former case, for the following effect on macro-heavy
crates.
- It reduces the total number of allocations a lot.
- It increases the size of some of the remaining allocations.
- It doesn't affect *peak* memory usage, because the larger allocations
  are short-lived.

This overall gives a speed win.
compiler/rustc_expand/src/mbe/macro_parser.rs
compiler/rustc_expand/src/mbe/macro_rules.rs
compiler/rustc_expand/src/mbe/transcribe.rs