Skip to content

Commit 7ebcecc

Browse files
[Performance] Full build takes more time since 2024-09 (type inference) (#3387)
optimize 3: + never visit the same super type more than once Fixes #3327
1 parent 1e3e3a9 commit 7ebcecc

File tree

1 file changed

+8
-2
lines changed
  • org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup

1 file changed

+8
-2
lines changed

org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/BoundSet.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1264,8 +1264,14 @@ private boolean superOnlyRaw(TypeBinding g, TypeBinding s, LookupEnvironment env
12641264
}
12651265

12661266
protected List<Pair<TypeBinding>> allSuperPairsWithCommonGenericType(TypeBinding s, TypeBinding t) {
1267+
return allSuperPairsWithCommonGenericTypeRecursive(s, t, new HashSet<>());
1268+
}
1269+
1270+
private List<Pair<TypeBinding>> allSuperPairsWithCommonGenericTypeRecursive(TypeBinding s, TypeBinding t, HashSet<TypeBinding> visited) {
12671271
if (s == null || s.id == TypeIds.T_JavaLangObject || t == null || t.id == TypeIds.T_JavaLangObject)
12681272
return Collections.emptyList();
1273+
if (!visited.add(s.prototype()))
1274+
return Collections.emptyList();
12691275
List<Pair<TypeBinding>> result = new ArrayList<>();
12701276
if (s.isParameterizedType() && t.isParameterizedType() // optimization #1: clients of this method only want to compare type arguments
12711277
&& TypeBinding.equalsEquals(s.original(), t.original())) {
@@ -1277,11 +1283,11 @@ protected List<Pair<TypeBinding>> allSuperPairsWithCommonGenericType(TypeBinding
12771283
if (tSuper != null && s.isParameterizedType() && tSuper.isParameterizedType()) { // optimization #1 again
12781284
result.add(new Pair<>(s, tSuper));
12791285
}
1280-
result.addAll(allSuperPairsWithCommonGenericType(s.superclass(), t));
1286+
result.addAll(allSuperPairsWithCommonGenericTypeRecursive(s.superclass(), t, visited));
12811287
ReferenceBinding[] superInterfaces = s.superInterfaces();
12821288
if (superInterfaces != null) {
12831289
for (ReferenceBinding superInterface : superInterfaces) {
1284-
result.addAll(allSuperPairsWithCommonGenericType(superInterface, t));
1290+
result.addAll(allSuperPairsWithCommonGenericTypeRecursive(superInterface, t, visited));
12851291
}
12861292
}
12871293
return result;

0 commit comments

Comments
 (0)