about summary refs log tree commit diff
diff options
context:
space:
mode:
authorNicholas Nethercote <n.nethercote@gmail.com>2022-03-23 13:09:55 +1100
committerNicholas Nethercote <n.nethercote@gmail.com>2022-03-25 12:35:56 +1100
commitcad5f1e7742e46ce16dc54d38516301e3ae72a9e (patch)
tree279a70140c079ddcb005abd62c48a0526ddeafdc
parent6817442ec7d9f29abfb080314f3c45ff5e3e633a (diff)
downloadrust-cad5f1e7742e46ce16dc54d38516301e3ae72a9e.tar.gz
rust-cad5f1e7742e46ce16dc54d38516301e3ae72a9e.zip
Shrink `NamedMatchVec` to one inline element.
This counters the `NamedMatchVec` size increase from the previous
commit, leaving `NamedMatchVec` smaller than before.
-rw-r--r--compiler/rustc_expand/src/mbe/macro_parser.rs7
1 files changed, 5 insertions, 2 deletions
diff --git a/compiler/rustc_expand/src/mbe/macro_parser.rs b/compiler/rustc_expand/src/mbe/macro_parser.rs
index f2090899e99..63c43cc8a33 100644
--- a/compiler/rustc_expand/src/mbe/macro_parser.rs
+++ b/compiler/rustc_expand/src/mbe/macro_parser.rs
@@ -101,11 +101,14 @@ struct MatcherTtFrame<'tt> {
     idx: usize,
 }
 
-type NamedMatchVec = SmallVec<[NamedMatch; 4]>;
+// One element is enough to cover 95-99% of vectors for most benchmarks. Also,
+// vectors longer than one frequently have many elements, not just two or
+// three.
+type NamedMatchVec = SmallVec<[NamedMatch; 1]>;
 
 // This type is used a lot. Make sure it doesn't unintentionally get bigger.
 #[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]
-rustc_data_structures::static_assert_size!(NamedMatchVec, 168);
+rustc_data_structures::static_assert_size!(NamedMatchVec, 48);
 
 /// Represents a single "position" (aka "matcher position", aka "item"), as
 /// described in the module documentation.