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

Delete PathFinder::FindAnyPathToNode method as it's not at all used besides tests. #1850

Merged
merged 1 commit into from
Dec 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 0 additions & 22 deletions pytype/typegraph/solver.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
#include <vector>

#include "cfg_logging.h"
#include "map_util.h"
#include "metrics.h"
#include "typegraph.h"

Expand Down Expand Up @@ -151,27 +150,6 @@ QueryResult PathCacheTrie::GetResult(const CFGNode* start,
return {false, nullptr};
}

bool PathFinder::FindAnyPathToNode(
const CFGNode* start,
const CFGNode* finish,
const CFGNodeSet& blocked) const {
std::vector<const CFGNode*> stack;
stack.push_back(start);
CFGNodeSet seen;
const CFGNode* node;
while (!stack.empty()) {
node = stack.back();
stack.pop_back();
if (node == finish)
return true;
if (seen.count(node) || blocked.count(node))
continue;
seen.insert(node);
stack.insert(stack.end(), node->incoming().begin(), node->incoming().end());
}
return false;
}

std::deque<const CFGNode*> PathFinder::FindShortestPathToNode(
const CFGNode* start, const CFGNode* finish,
const CFGNodeSet& blocked) const {
Expand Down
4 changes: 0 additions & 4 deletions pytype/typegraph/solver.h
Original file line number Diff line number Diff line change
Expand Up @@ -150,10 +150,6 @@ class PathFinder {
PathFinder(const PathFinder&) = delete;
PathFinder& operator=(const PathFinder&) = delete;

// Determine whether we can reach a node at all.
bool FindAnyPathToNode(const CFGNode* start, const CFGNode* finish,
const CFGNodeSet& blocked) const;

// Find a shortest path from start to finish, going backwards. Returns an
// empty path if no path exists.
std::deque<const CFGNode*> FindShortestPathToNode(
Expand Down
7 changes: 0 additions & 7 deletions pytype/typegraph/solver_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -350,13 +350,6 @@ TEST(SolverTest, TestPathFinder) {
CFGNode* n5 = n4->ConnectNew("n5");
n5->ConnectTo(n5);
internal::PathFinder f;
EXPECT_TRUE(f.FindAnyPathToNode(n1, n1, {}));
EXPECT_TRUE(f.FindAnyPathToNode(n1, n1, {n1}));
EXPECT_TRUE(f.FindAnyPathToNode(n4, n1, {n1}));
EXPECT_TRUE(f.FindAnyPathToNode(n4, n1, {n2}));
EXPECT_TRUE(f.FindAnyPathToNode(n4, n1, {n3}));
EXPECT_FALSE(f.FindAnyPathToNode(n4, n1, {n4}));
EXPECT_FALSE(f.FindAnyPathToNode(n4, n1, {n2, n3}));
EXPECT_THAT(f.FindShortestPathToNode(n1, n1, {}), ElementsAre(n1));
EXPECT_THAT(f.FindShortestPathToNode(n1, n1, {n1}), ElementsAre(n1));
EXPECT_FALSE(f.FindShortestPathToNode(n4, n1, {n1}).empty());
Expand Down
Loading