Skip to content

Commit cad5f1e

Browse files
committed
Shrink NamedMatchVec to one inline element.
This counters the `NamedMatchVec` size increase from the previous commit, leaving `NamedMatchVec` smaller than before.
1 parent 6817442 commit cad5f1e

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

compiler/rustc_expand/src/mbe/macro_parser.rs

+5-2
Original file line numberDiff line numberDiff line change
@@ -101,11 +101,14 @@ struct MatcherTtFrame<'tt> {
101101
idx: usize,
102102
}
103103

104-
type NamedMatchVec = SmallVec<[NamedMatch; 4]>;
104+
// One element is enough to cover 95-99% of vectors for most benchmarks. Also,
105+
// vectors longer than one frequently have many elements, not just two or
106+
// three.
107+
type NamedMatchVec = SmallVec<[NamedMatch; 1]>;
105108

106109
// This type is used a lot. Make sure it doesn't unintentionally get bigger.
107110
#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]
108-
rustc_data_structures::static_assert_size!(NamedMatchVec, 168);
111+
rustc_data_structures::static_assert_size!(NamedMatchVec, 48);
109112

110113
/// Represents a single "position" (aka "matcher position", aka "item"), as
111114
/// described in the module documentation.

0 commit comments

Comments
 (0)