Skip to content

Commit

Permalink
Rollup merge of rust-lang#52641 - ljedrz:mir_dataflow_misc, r=cramertj
Browse files Browse the repository at this point in the history
Simplify 2 functions in rustc_mir/dataflow

- `graphviz::outgoing`: the `enumerate` only provides indices; use a range instead
- `DataflowState::interpret_set`: change a push loop to an iterator and remove the `each_bit` helper function
  • Loading branch information
kennytm committed Jul 24, 2018
2 parents b3c9fe2 + d89ac4c commit 378ef99
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 12 deletions.
4 changes: 2 additions & 2 deletions src/librustc_mir/dataflow/graphviz.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ pub type Node = BasicBlock;
pub struct Edge { source: BasicBlock, index: usize }

fn outgoing(mir: &Mir, bb: BasicBlock) -> Vec<Edge> {
mir[bb].terminator().successors().enumerate()
.map(|(index, _)| Edge { source: bb, index: index}).collect()
(0..mir[bb].terminator().successors().count())
.map(|index| Edge { source: bb, index: index}).collect()
}

impl<'a, 'tcx, MWF, P> dot::Labeller<'a> for Graph<'a, 'tcx, MWF, P>
Expand Down
11 changes: 1 addition & 10 deletions src/librustc_mir/dataflow/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -441,23 +441,14 @@ pub struct DataflowState<O: BitDenotation>
}

impl<O: BitDenotation> DataflowState<O> {
pub fn each_bit<F>(&self, words: &IdxSet<O::Idx>, f: F) where F: FnMut(O::Idx)
{
words.iter().for_each(f)
}

pub(crate) fn interpret_set<'c, P>(&self,
o: &'c O,
words: &IdxSet<O::Idx>,
render_idx: &P)
-> Vec<DebugFormatted>
where P: Fn(&O, O::Idx) -> DebugFormatted
{
let mut v = Vec::new();
self.each_bit(words, |i| {
v.push(render_idx(o, i));
});
v
words.iter().map(|i| render_idx(o, i)).collect()
}
}

Expand Down

0 comments on commit 378ef99

Please sign in to comment.