Use SmallVec in SwitchTargets

This allows building common SwitchTargets (eg. for `if`s) without
allocation.
This commit is contained in:
Jonas Schievink
2020-10-11 01:14:12 +02:00
parent 432535da2b
commit 9a47f74bfe
5 changed files with 14 additions and 15 deletions

View File

@@ -760,8 +760,6 @@ where
let elem_size = Place::from(self.new_temp(tcx.types.usize));
let len = Place::from(self.new_temp(tcx.types.usize));
static USIZE_SWITCH_ZERO: &[u128; 1] = &[0];
let base_block = BasicBlockData {
statements: vec![
self.assign(elem_size, Rvalue::NullaryOp(NullOp::SizeOf, ety)),
@@ -774,7 +772,7 @@ where
discr: move_(elem_size),
switch_ty: tcx.types.usize,
targets: SwitchTargets::static_if(
USIZE_SWITCH_ZERO,
0,
self.drop_loop_pair(ety, false, len),
self.drop_loop_pair(ety, true, len),
),