@@ -721,7 +721,7 @@ impl<'p, 'tcx> fmt::Debug for MatrixRow<'p, 'tcx> {
721
721
/// the matrix will correspond to `scrutinee.0.Some.0` and the second column to `scrutinee.1`.
722
722
#[ derive( Clone ) ]
723
723
struct Matrix < ' p , ' tcx > {
724
- rows : Vec < MatrixRow < ' p , ' tcx > > ,
724
+ rows : SmallVec < [ MatrixRow < ' p , ' tcx > ; 8 ] > ,
725
725
/// Stores an extra fictitious row full of wildcards. Mostly used to keep track of the type of
726
726
/// each column. This must obey the same invariants as the real rows.
727
727
wildcard_row : PatStack < ' p , ' tcx > ,
@@ -745,7 +745,7 @@ impl<'p, 'tcx> Matrix<'p, 'tcx> {
745
745
fn new ( cx : & MatchCheckCtxt < ' p , ' tcx > , arms : & [ MatchArm < ' p , ' tcx > ] , scrut_ty : Ty < ' tcx > ) -> Self {
746
746
let wild_pattern = cx. pattern_arena . alloc ( DeconstructedPat :: wildcard ( scrut_ty, DUMMY_SP ) ) ;
747
747
let wildcard_row = PatStack :: from_pattern ( cx, wild_pattern) ;
748
- let mut matrix = Matrix { rows : Vec :: with_capacity ( arms. len ( ) ) , wildcard_row } ;
748
+ let mut matrix = Matrix { rows : SmallVec :: with_capacity ( arms. len ( ) ) , wildcard_row } ;
749
749
for ( row_id, arm) in arms. iter ( ) . enumerate ( ) {
750
750
let v = MatrixRow {
751
751
pats : PatStack :: from_pattern ( cx, arm. pat ) ,
@@ -809,7 +809,7 @@ impl<'p, 'tcx> Matrix<'p, 'tcx> {
809
809
ctor : & Constructor < ' tcx > ,
810
810
) -> Matrix < ' p , ' tcx > {
811
811
let wildcard_row = self . wildcard_row . pop_head_constructor ( pcx, ctor) ;
812
- let rows = Vec :: with_capacity ( self . rows . len ( ) ) ; // Better waste capacity than reallocate a lot.
812
+ let rows = SmallVec :: with_capacity ( self . rows . len ( ) ) ; // Better waste capacity than reallocate a lot.
813
813
let mut matrix = Matrix { rows, wildcard_row } ;
814
814
for ( i, row) in self . rows ( ) . enumerate ( ) {
815
815
if ctor. is_covered_by ( pcx, row. head ( ) . ctor ( ) ) {
0 commit comments