Skip to content

Commit

Permalink
Auto merge of rust-lang#66540 - nnethercote:SmallVec-Candidate-match_…
Browse files Browse the repository at this point in the history
…pairs, r=matthewjasper

Use a `SmallVec` for `Candidate::match_pairs`.

This is a small win for `encoding`.

r? @matthewjasper
  • Loading branch information
bors committed Nov 24, 2019
2 parents 412f43a + 4c33a5a commit 388ffd9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
7 changes: 4 additions & 3 deletions src/librustc_mir/build/matches/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ use rustc::ty::{self, CanonicalUserTypeAnnotation, Ty};
use rustc::ty::layout::VariantIdx;
use rustc_index::bit_set::BitSet;
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
use smallvec::{SmallVec, smallvec};
use syntax::ast::Name;
use syntax_pos::Span;

Expand Down Expand Up @@ -166,7 +167,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|(pattern, pre_binding_block)| {
Candidate {
span: pattern.span,
match_pairs: vec![
match_pairs: smallvec![
MatchPair::new(scrutinee_place.clone(), pattern),
],
bindings: vec![],
Expand Down Expand Up @@ -421,7 +422,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
// create a dummy candidate
let mut candidate = Candidate {
span: irrefutable_pat.span,
match_pairs: vec![MatchPair::new(initializer.clone(), &irrefutable_pat)],
match_pairs: smallvec![MatchPair::new(initializer.clone(), &irrefutable_pat)],
bindings: vec![],
ascriptions: vec![],

Expand Down Expand Up @@ -671,7 +672,7 @@ pub struct Candidate<'pat, 'tcx> {
span: Span,

// all of these must be satisfied...
match_pairs: Vec<MatchPair<'pat, 'tcx>>,
match_pairs: SmallVec<[MatchPair<'pat, 'tcx>; 1]>,

// ...these bindings established...
bindings: Vec<Binding<'tcx>>,
Expand Down
3 changes: 2 additions & 1 deletion src/librustc_mir/build/matches/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use crate::build::Builder;
use crate::build::matches::MatchPair;
use crate::hair::*;
use rustc::mir::*;
use smallvec::SmallVec;
use std::u32;
use std::convert::TryInto;

Expand All @@ -25,7 +26,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
}

pub fn prefix_slice_suffix<'pat>(&mut self,
match_pairs: &mut Vec<MatchPair<'pat, 'tcx>>,
match_pairs: &mut SmallVec<[MatchPair<'pat, 'tcx>; 1]>,
place: &Place<'tcx>,
prefix: &'pat [Pat<'tcx>],
opt_slice: Option<&'pat Pat<'tcx>>,
Expand Down

0 comments on commit 388ffd9

Please sign in to comment.