Skip to content

Commit 3a37978

Browse files
committed
simplify.rs smallvecs
1 parent 7908a1d commit 3a37978

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

compiler/rustc_mir_transform/src/simplify.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
//! return.
2929
3030
use crate::MirPass;
31-
use rustc_data_structures::fx::{FxHashSet, FxIndexSet};
31+
use rustc_data_structures::fx::FxHashSet;
3232
use rustc_index::vec::{Idx, IndexSlice, IndexVec};
3333
use rustc_middle::mir::coverage::*;
3434
use rustc_middle::mir::visit::{MutVisitor, MutatingUseContext, PlaceContext, Visitor};
@@ -99,7 +99,7 @@ impl<'a, 'tcx> CfgSimplifier<'a, 'tcx> {
9999
// statements itself to avoid moving the (relatively) large statements twice.
100100
// We do not push the statements directly into the target block (`bb`) as that is slower
101101
// due to additional reallocations
102-
let mut merged_blocks = Vec::new();
102+
let mut merged_blocks = SmallVec::new();
103103
loop {
104104
let mut changed = false;
105105

@@ -203,7 +203,7 @@ impl<'a, 'tcx> CfgSimplifier<'a, 'tcx> {
203203
// merge a block with 1 `goto` predecessor to its parent
204204
fn merge_successor(
205205
&mut self,
206-
merged_blocks: &mut Vec<BasicBlock>,
206+
merged_blocks: &mut SmallVec<[BasicBlock; 2]>,
207207
terminator: &mut Terminator<'tcx>,
208208
) -> bool {
209209
let target = match terminator.kind {
@@ -263,7 +263,7 @@ impl<'a, 'tcx> CfgSimplifier<'a, 'tcx> {
263263
pub fn remove_duplicate_unreachable_blocks<'tcx>(tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) {
264264
struct OptApplier<'tcx> {
265265
tcx: TyCtxt<'tcx>,
266-
duplicates: FxIndexSet<BasicBlock>,
266+
duplicates: SmallVec<[BasicBlock; 2]>,
267267
}
268268

269269
impl<'tcx> MutVisitor<'tcx> for OptApplier<'tcx> {
@@ -296,7 +296,7 @@ pub fn remove_duplicate_unreachable_blocks<'tcx>(tcx: TyCtxt<'tcx>, body: &mut B
296296
bb.terminator.is_some() && bb.is_empty_unreachable() && !bb.is_cleanup
297297
})
298298
.map(|(block, _)| block)
299-
.collect::<FxIndexSet<_>>();
299+
.collect::<SmallVec<[_; 2]>>();
300300

301301
if unreachable_blocks.len() > 1 {
302302
OptApplier { tcx, duplicates: unreachable_blocks }.visit_body(body);

0 commit comments

Comments
 (0)