diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/IndexFileSet.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/IndexFileSet.java index 6388221ca7c..32a47cd4c9a 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/IndexFileSet.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/IndexFileSet.java @@ -100,6 +100,11 @@ public class IndexFileSet implements IIndexFileSet { Set 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); @@ -114,12 +119,6 @@ public class IndexFileSet implements IIndexFileSet { } 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) {