Skip to content

Commit

Permalink
perf(semantic/cfg): lower the visits in `neighbors_filtered_by_edge_w…
Browse files Browse the repository at this point in the history
…eight`. (#3676)

related to #3407
  • Loading branch information
rzvxa committed Jun 14, 2024
1 parent bd8d115 commit 2717a1a
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions crates/oxc_semantic/src/pg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
Expand Down

0 comments on commit 2717a1a

Please sign in to comment.