1
Fork 0

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

@ -514,7 +514,7 @@ impl Direction for Forward {
struct SwitchIntEdgeEffectApplier<'a, D, F> {
exit_state: &'a mut D,
targets: &'a SwitchTargets<'a>,
targets: &'a SwitchTargets,
propagate: F,
effects_applied: bool,

View file

@ -227,5 +227,5 @@ struct OptimizationInfo<'tcx> {
/// Either Eq or Ne
op: BinOp,
/// Current targets used in the switch
targets: SwitchTargets<'tcx>,
targets: SwitchTargets,
}

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),
),