about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorNicholas Nethercote <nnethercote@mozilla.com>2019-11-19 17:55:59 +1100
committerNicholas Nethercote <nnethercote@mozilla.com>2019-11-19 17:55:59 +1100
commit4c33a5ac2f93ca2e4d0fb53bd8ecbcdffb8b23e2 (patch)
tree5b61fa475f44df78efc208a72e5462b181373e86 /src
parent0f0c640e0ee5a9ad365e78e3c62239b3d65b7045 (diff)
downloadrust-4c33a5ac2f93ca2e4d0fb53bd8ecbcdffb8b23e2.tar.gz
rust-4c33a5ac2f93ca2e4d0fb53bd8ecbcdffb8b23e2.zip
Use a `SmallVec` for `Candidate::match_pairs`.
This is a small win for `encoding`.
Diffstat (limited to 'src')
-rw-r--r--src/librustc_mir/build/matches/mod.rs7
-rw-r--r--src/librustc_mir/build/matches/util.rs3
2 files changed, 6 insertions, 4 deletions
diff --git a/src/librustc_mir/build/matches/mod.rs b/src/librustc_mir/build/matches/mod.rs
index 667b37bbd80..d33ddd1ecae 100644
--- a/src/librustc_mir/build/matches/mod.rs
+++ b/src/librustc_mir/build/matches/mod.rs
@@ -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;
 
@@ -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![],
@@ -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![],
 
@@ -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>>,
diff --git a/src/librustc_mir/build/matches/util.rs b/src/librustc_mir/build/matches/util.rs
index 917535f31dc..aec9e6e57d4 100644
--- a/src/librustc_mir/build/matches/util.rs
+++ b/src/librustc_mir/build/matches/util.rs
@@ -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;
 
@@ -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>>,