Skip to content

Problem: Performance discrepancy when filtering by getCompilationUnit vs. getSignature in a query #14071

Answered by smowton
oriana19993926782 asked this question in Q&A
Discussion options

You must be logged in to vote

Your fundamental problem is that cycles in the call graph (due to real recursion, or apparent recursion via virtual dispatch that can't really happen in practice) mean that getCallDepth taken in isolation could calculate a potentially infinite number of answers for a particular (start, target) pair. In the simple example where f calls g and itself, then (f, g) has distance 1, 2, 3, 4, ...

There are two options here depending on whether you care about such loops: take the shortest distance, or limit the distance to some fixed maximum value using a simple result < 100 sort of side condition.

For shortest distance calculations there is a higher-order predicate shortestDistance that takes a u…

Replies: 2 comments 3 replies

Comment options

You must be logged in to vote
0 replies
Answer selected by oriana19993926782
Comment options

You must be logged in to vote
3 replies
@smowton
Comment options

@oriana19993926782
Comment options

@smowton
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants