Skip to content

Commit

Permalink
Restore counting iterations in computeContainsDeclaration cycle detector
Browse files Browse the repository at this point in the history
A follow-up change to bug 509898 missed actually incrementing the counter,
restore it now.

Fixes: 5462bac ("Bug 509898 - IndexFileSet.containsDeclaration is slow and is causing UI freezes")
  • Loading branch information
i-garrison authored and jonahgraham committed Mar 16, 2023
1 parent 65ac74f commit f76fb34
Showing 1 changed file with 5 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,11 @@ private boolean computeContainsDeclaration(IIndexBinding binding) {
Set<Long> visited = null;
long nameRecord;
while ((nameRecord = nameIterator.next()) != 0) {
if (++iterationCount >= 1000 && visited == null) {
// Iteration count is suspiciously high. Start keeping track of visited names
// to be able to detect a cycle.
visited = new HashSet<>();
}
if (visited != null && !visited.add(nameRecord)) {
// Cycle detected!
logInvalidNameChain(pdom, binding);
Expand All @@ -114,12 +119,6 @@ private boolean computeContainsDeclaration(IIndexBinding binding) {
}
return true;
}
if (iterationCount >= 1000 && visited == null) {
// Iteration count is suspiciously high. Start keeping track of visited names
// to be able to detect a cycle.
visited = new HashSet<>();
visited.add(nameRecord);
}
}
}
} catch (CoreException e) {
Expand Down

0 comments on commit f76fb34

Please sign in to comment.