mirror of
https://github.com/danbulant/oxc
synced 2026-05-19 12:19:15 +00:00
perf(semantic/cfg): lower the visits in neighbors_filtered_by_edge_weight. (#3676)
related to #3407
This commit is contained in:
parent
bd8d1152f1
commit
2717a1a5b7
1 changed files with 8 additions and 8 deletions
|
|
@ -29,19 +29,19 @@ where
|
|||
|
||||
while let Some((graph_ix, state)) = q.pop() {
|
||||
let mut edges = 0;
|
||||
if visited.contains(&graph_ix) {
|
||||
continue;
|
||||
}
|
||||
visited.insert(graph_ix);
|
||||
|
||||
for edge in graph.edges_directed(graph_ix, Direction::Outgoing) {
|
||||
if visited.contains(&edge.target()) {
|
||||
continue;
|
||||
}
|
||||
if let Some(result_of_edge_filtering) = edge_filter(edge.weight()) {
|
||||
final_states.push(result_of_edge_filtering);
|
||||
} else {
|
||||
let opposite_dir_of_edge_graph_ix = edge.target();
|
||||
let (new_state, keep_walking_this_path) =
|
||||
visitor(&opposite_dir_of_edge_graph_ix, state.clone());
|
||||
let target = edge.target();
|
||||
let (new_state, keep_walking_this_path) = visitor(&target, state.clone());
|
||||
visited.insert(target);
|
||||
if keep_walking_this_path {
|
||||
q.push((opposite_dir_of_edge_graph_ix, new_state.clone()));
|
||||
q.push((target, new_state.clone()));
|
||||
} else {
|
||||
final_states.push(new_state.clone());
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue