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

[Performance] Full build takes more time since 2024-09 (type inference) #3387

Merged
merged 1 commit into from
Dec 4, 2024
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -1264,8 +1264,14 @@ private boolean superOnlyRaw(TypeBinding g, TypeBinding s, LookupEnvironment env
}

protected List<Pair<TypeBinding>> allSuperPairsWithCommonGenericType(TypeBinding s, TypeBinding t) {
return allSuperPairsWithCommonGenericTypeRecursive(s, t, new HashSet<>());
}

private List<Pair<TypeBinding>> allSuperPairsWithCommonGenericTypeRecursive(TypeBinding s, TypeBinding t, HashSet<TypeBinding> visited) {
if (s == null || s.id == TypeIds.T_JavaLangObject || t == null || t.id == TypeIds.T_JavaLangObject)
return Collections.emptyList();
if (!visited.add(s.prototype()))
return Collections.emptyList();
List<Pair<TypeBinding>> result = new ArrayList<>();
if (s.isParameterizedType() && t.isParameterizedType() // optimization #1: clients of this method only want to compare type arguments
&& TypeBinding.equalsEquals(s.original(), t.original())) {
Expand All @@ -1277,11 +1283,11 @@ protected List<Pair<TypeBinding>> allSuperPairsWithCommonGenericType(TypeBinding
if (tSuper != null && s.isParameterizedType() && tSuper.isParameterizedType()) { // optimization #1 again
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Assuming s.isParameterizedType is a very cheap operation and findSuperTypeOriginatingFrom is not:
The lookup of tSuper can be guarded by s.isParameterizedType():

TypeBinding tSuper = s.isParameterizedType() ? t.findSuperTypeOriginatingFrom(s) : null;
if (tSuper != null && tSuper.isParameterizedType()) {
  result.add(new Pair<>(s, tSuper));
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can try this tomorrow and report back. Thank you for the hint!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Incredible... I had to sample twice because I couldn't believe my eyes 😄

Thank you, @szarnekow ! --> #3411

result.add(new Pair<>(s, tSuper));
}
result.addAll(allSuperPairsWithCommonGenericType(s.superclass(), t));
result.addAll(allSuperPairsWithCommonGenericTypeRecursive(s.superclass(), t, visited));
ReferenceBinding[] superInterfaces = s.superInterfaces();
if (superInterfaces != null) {
for (ReferenceBinding superInterface : superInterfaces) {
result.addAll(allSuperPairsWithCommonGenericType(superInterface, t));
result.addAll(allSuperPairsWithCommonGenericTypeRecursive(superInterface, t, visited));
}
}
return result;
Expand Down
Loading