Skip to content
This repository was archived by the owner on Sep 9, 2025. It is now read-only.

Commit 7a30932

Browse files
author
Hendrik van Antwerpen
committed
Remove similar path detection from path finding
1 parent 93aaa64 commit 7a30932

File tree

2 files changed

+7
-33
lines changed

2 files changed

+7
-33
lines changed

stack-graphs/src/partial.rs

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ use crate::arena::DequeArena;
4848
use crate::arena::Handle;
4949
use crate::cycles::Appendables;
5050
use crate::cycles::AppendingCycleDetector;
51-
use crate::cycles::SimilarPathDetector;
5251
use crate::graph::Edge;
5352
use crate::graph::File;
5453
use crate::graph::Node;
@@ -2465,7 +2464,6 @@ impl PartialPath {
24652464
file: Handle<File>,
24662465
edges: &mut Appendables<Edge>,
24672466
path_cycle_detector: AppendingCycleDetector<Edge>,
2468-
similar_path_detector: &mut SimilarPathDetector<PartialPath>,
24692467
result: &mut R,
24702468
) {
24712469
let extensions = graph.outgoing_edges(self.end_node);
@@ -2487,15 +2485,9 @@ impl PartialPath {
24872485
copious_debugging!(" * invalid extension");
24882486
continue;
24892487
}
2490-
if similar_path_detector.has_similar_path(
2491-
graph,
2492-
partials,
2493-
&new_path,
2494-
|ps, left, right| left.equals(ps, right),
2495-
) {
2496-
copious_debugging!(" * too many similar");
2497-
continue;
2498-
}
2488+
// We assume languages do not introduce similar paths (paths between the same nodes with
2489+
// equivalent pre- and postconditions), so we do not guard against that here. We may need
2490+
// to revisit that assumption in the future.
24992491
let mut new_cycle_detector = path_cycle_detector.clone();
25002492
new_cycle_detector.append(edges, extension);
25012493
result.push((new_path, new_cycle_detector));
@@ -2803,7 +2795,6 @@ impl PartialPaths {
28032795
}
28042796

28052797
copious_debugging!("Find all partial paths in {}", graph[file]);
2806-
let mut similar_path_detector = SimilarPathDetector::new();
28072798
let mut queue = VecDeque::new();
28082799
let mut edges = Appendables::new();
28092800
queue.extend(
@@ -2839,15 +2830,10 @@ impl PartialPaths {
28392830
file,
28402831
&mut edges,
28412832
path_cycle_detector,
2842-
&mut similar_path_detector,
28432833
&mut queue,
28442834
);
28452835
}
28462836
}
2847-
copious_debugging!(
2848-
" Max similar path bucket size: {}",
2849-
similar_path_detector.max_bucket_size()
2850-
);
28512837
Ok(())
28522838
}
28532839
}

stack-graphs/src/paths.rs

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ use crate::arena::List;
2828
use crate::arena::ListArena;
2929
use crate::cycles::Appendables;
3030
use crate::cycles::AppendingCycleDetector;
31-
use crate::cycles::SimilarPathDetector;
3231
use crate::graph::Edge;
3332
use crate::graph::Node;
3433
use crate::graph::NodeID;
@@ -879,7 +878,6 @@ impl Path {
879878
paths: &mut Paths,
880879
edges: &mut Appendables<Edge>,
881880
path_cycle_detector: AppendingCycleDetector<Edge>,
882-
similar_path_detector: &mut SimilarPathDetector<Path>,
883881
result: &mut R,
884882
) {
885883
let extensions = graph.outgoing_edges(self.end_node);
@@ -891,11 +889,9 @@ impl Path {
891889
if new_path.append(graph, paths, extension).is_err() {
892890
continue;
893891
}
894-
if similar_path_detector.has_similar_path(graph, paths, &new_path, |ps, left, right| {
895-
left.equals(ps, right)
896-
}) {
897-
continue;
898-
}
892+
// We assume languages do not introduce similar paths (paths between the same nodes with
893+
// equivalent pre- and postconditions), so we do not guard against that here. We may need
894+
// to revisit that assumption in the future.
899895
let mut new_cycle_detector = path_cycle_detector.clone();
900896
new_cycle_detector.append(edges, extension);
901897
result.push((new_path, new_cycle_detector));
@@ -924,7 +920,6 @@ impl Paths {
924920
I: IntoIterator<Item = Handle<Node>>,
925921
F: FnMut(&StackGraph, &mut Paths, Path),
926922
{
927-
let mut similar_path_detector = SimilarPathDetector::new();
928923
let mut queue = starting_nodes
929924
.into_iter()
930925
.filter_map(|node| {
@@ -943,14 +938,7 @@ impl Paths {
943938
.all(|c| c == Cyclicity::StrengthensPrecondition)
944939
{
945940
} else {
946-
path.extend(
947-
graph,
948-
self,
949-
&mut edges,
950-
path_cycle_detector,
951-
&mut similar_path_detector,
952-
&mut queue,
953-
);
941+
path.extend(graph, self, &mut edges, path_cycle_detector, &mut queue);
954942
}
955943
}
956944
Ok(())

0 commit comments

Comments
 (0)