Avoid a heap allocation.

This commit is contained in:
Dan Gohman
2017-09-21 09:24:18 -07:00
parent 22b769b716
commit ff18772d0e

View File

@@ -138,7 +138,6 @@ impl<'short, 'long, Variable> InstBuilderBase<'short> for FuncInstBuilder<'short
None => { None => {
// branch_destination() doesn't detect jump_tables // branch_destination() doesn't detect jump_tables
// If jump table we declare all entries successor // If jump table we declare all entries successor
// TODO: not collect with vector?
if let InstructionData::BranchTable { table, .. } = data { if let InstructionData::BranchTable { table, .. } = data {
// Unlike all other jumps/branches, jump tables are // Unlike all other jumps/branches, jump tables are
// capable of having the same successor appear // capable of having the same successor appear
@@ -151,9 +150,12 @@ impl<'short, 'long, Variable> InstBuilderBase<'short> for FuncInstBuilder<'short
.expect("you are referencing an undeclared jump table") .expect("you are referencing an undeclared jump table")
.entries() .entries()
.map(|(_, ebb)| ebb) .map(|(_, ebb)| ebb)
.filter(|dest_ebb| unique.insert(*dest_ebb)) .filter(|dest_ebb| unique.insert(*dest_ebb)) {
.collect::<Vec<Ebb>>() { self.builder.builder.ssa.declare_ebb_predecessor(
self.builder.declare_successor(dest_ebb, inst) dest_ebb,
self.builder.position.basic_block,
inst,
)
} }
} }
} }