diff options
| author | bors <bors@rust-lang.org> | 2023-05-02 15:05:28 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2023-05-02 15:05:28 +0000 |
| commit | 4ecd7e6c0d25ed9a83bf94e49c63d0b6919c22f0 (patch) | |
| tree | 879d282e143f38bb8ce7b5520211761f9c0f0843 | |
| parent | a48e0e14e15abf47feae17e54d149eb443729375 (diff) | |
| parent | 90499d4390402ae174f6a2e029b46ade92545496 (diff) | |
| download | rust-4ecd7e6c0d25ed9a83bf94e49c63d0b6919c22f0.tar.gz rust-4ecd7e6c0d25ed9a83bf94e49c63d0b6919c22f0.zip | |
Auto merge of #14720 - Veykril:boxed-slices, r=Veykril
internal: Use boxed slices instead ovecs in decl macros saves another 10 mb on self (since we didn't shrink the vecs)
| -rw-r--r-- | crates/mbe/src/benchmark.rs | 2 | ||||
| -rw-r--r-- | crates/mbe/src/lib.rs | 6 | ||||
| -rw-r--r-- | crates/mbe/src/parser.rs | 4 |
3 files changed, 6 insertions, 6 deletions
diff --git a/crates/mbe/src/benchmark.rs b/crates/mbe/src/benchmark.rs index 212e0a02dbc..d640eea19a2 100644 --- a/crates/mbe/src/benchmark.rs +++ b/crates/mbe/src/benchmark.rs @@ -79,7 +79,7 @@ fn invocation_fixtures(rules: &FxHashMap<String, DeclarativeMacro>) -> Vec<(Stri let mut res = Vec::new(); for (name, it) in rules { - for rule in &it.rules { + for rule in it.rules.iter() { // Generate twice for _ in 0..2 { // The input are generated by filling the `Op` randomly. diff --git a/crates/mbe/src/lib.rs b/crates/mbe/src/lib.rs index d20641062c1..80352aa4adc 100644 --- a/crates/mbe/src/lib.rs +++ b/crates/mbe/src/lib.rs @@ -104,7 +104,7 @@ impl fmt::Display for ExpandError { /// and `$()*` have special meaning (see `Var` and `Repeat` data structures) #[derive(Clone, Debug, PartialEq, Eq)] pub struct DeclarativeMacro { - rules: Vec<Rule>, + rules: Box<[Rule]>, /// Highest id of the token we have in TokenMap shift: Shift, // This is used for correctly determining the behavior of the pat fragment @@ -217,7 +217,7 @@ impl DeclarativeMacro { validate(lhs)?; } - Ok(DeclarativeMacro { rules, shift: Shift::new(tt), is_2021 }) + Ok(DeclarativeMacro { rules: rules.into_boxed_slice(), shift: Shift::new(tt), is_2021 }) } /// The new, unstable `macro m {}` flavor. @@ -250,7 +250,7 @@ impl DeclarativeMacro { validate(lhs)?; } - Ok(DeclarativeMacro { rules, shift: Shift::new(tt), is_2021 }) + Ok(DeclarativeMacro { rules: rules.into_boxed_slice(), shift: Shift::new(tt), is_2021 }) } pub fn expand(&self, tt: &tt::Subtree) -> ExpandResult<tt::Subtree> { diff --git a/crates/mbe/src/parser.rs b/crates/mbe/src/parser.rs index fd3d64719ac..0fbf832b06d 100644 --- a/crates/mbe/src/parser.rs +++ b/crates/mbe/src/parser.rs @@ -20,7 +20,7 @@ use crate::{tt, tt_iter::TtIter, ParseError}; /// Stuff to the right is a [`MetaTemplate`] template which is used to produce /// output. #[derive(Clone, Debug, PartialEq, Eq)] -pub(crate) struct MetaTemplate(pub(crate) Vec<Op>); +pub(crate) struct MetaTemplate(pub(crate) Box<[Op]>); impl MetaTemplate { pub(crate) fn parse_pattern(pattern: &tt::Subtree) -> Result<MetaTemplate, ParseError> { @@ -44,7 +44,7 @@ impl MetaTemplate { res.push(op); } - Ok(MetaTemplate(res)) + Ok(MetaTemplate(res.into_boxed_slice())) } } |
