Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Renamed infos for clarity, consistency, and succinctness #597

Open
wants to merge 17 commits into
base: pfb/extra-info
Choose a base branch
from
Open
Prev Previous commit
Next Next commit
better rust style
Co-authored-by: Khyber Sen <[email protected]>
  • Loading branch information
Peter Faith Boyland committed Aug 9, 2022
commit 577d4f1ae3d4908d401fbf924fce6417464460a1
8 changes: 4 additions & 4 deletions pdg/src/graph.rs
Original file line number Diff line number Diff line change
@@ -160,10 +160,10 @@ impl Node {
statement_idx,
};
let fn_ = function;
let info = match node_info {
None => format!(""),
Some(i) => format!("{i}"),
};
let info = node_info
.as_ref()
.map(|i| i.to_string())
.unwrap_or_default();
write!(
f,
"{kind}{sep}{src}{sep}=>{sep}{dest}{sep}@{sep}{bb_stmt}:{sep}fn {fn_};{sep}({info}){sep}{debug_info}"
30 changes: 14 additions & 16 deletions pdg/src/info.rs
Original file line number Diff line number Diff line change
@@ -63,13 +63,12 @@ fn node_does_neg_offset(n: &Node) -> bool {
}

fn add_children_to_vec(g: &Graph, parents: &HashSet<NodeId>, v: &mut Vec<NodeId>) {
for (possible_child_id, possible_child_node) in g.nodes.iter_enumerated() {
if let Some(srcidx) = possible_child_node.source {
if parents.contains(&srcidx) {
v.push(possible_child_id);
}
}
}
v.extend(g.nodes
.iter_enumerated()
.filter_map(|(id,node)| Some((id,node.source?)))
.filter(|(_,src_idx)| parents.contains(src_idx))
.map(|(id,_)| id)
);
}

fn check_flows_to_node_kind(
@@ -78,8 +77,7 @@ fn check_flows_to_node_kind(
node_check: fn(&Node) -> bool,
) -> Option<NodeId> {
let mut seen = HashSet::new();
let mut to_view = Vec::new();
to_view.push(*n);
let mut to_view = vec![*n];
while let Some(node_id_to_check) = to_view.pop() {
if !seen.contains(&node_id_to_check) {
seen.insert(node_id_to_check);
@@ -164,13 +162,13 @@ pub fn check_whether_rules_obeyed(g: &Graph, n: &NodeId) -> Option<NodeId> {
{
return Some(cur_node_id);
}
for (possible_child_id, possible_child_node) in g.nodes.iter_enumerated() {
if let Some(srcidx) = possible_child_node.source {
if cur_node_id == srcidx {
to_view.push((possible_child_id, lineage.clone()));
}
}
}
to_view.extend(
g.nodes
.iter_enumerated()
.filter_map(|(id,node)| Some((id,node.source?)))
.filter(|(_,src_idx)| *src_idx == cur_node_id)
.map(|(id,_)| (id,lineage.clone()))
);
}
None
}