changeset 55858:28f4594b19c2

8224161: Check.checkOverrideClashes n^2 algorithm Summary: Caching type's members in Check.checkOverrideClashes to improve performance. Reviewed-by: mcimadamore, jlahoda
author ronsh
date Thu, 13 Jun 2019 08:42:49 +0200
parents 6c8d5d0e1be4
children 5c4f1b7c753b
files src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Check.java
diffstat 1 files changed, 4 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Check.java	Thu Jun 13 08:42:47 2019 +0200
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Check.java	Thu Jun 13 08:42:49 2019 +0200
@@ -2421,7 +2421,9 @@
 
         List<MethodSymbol> potentiallyAmbiguousList = List.nil();
         boolean overridesAny = false;
-        for (Symbol m1 : types.membersClosure(site, false).getSymbolsByName(sym.name, cf)) {
+        ArrayList<Symbol> symbolsByName = new ArrayList<>();
+        types.membersClosure(site, false).getSymbolsByName(sym.name, cf).forEach(symbolsByName::add);
+        for (Symbol m1 : symbolsByName) {
             if (!sym.overrides(m1, site.tsym, types, false)) {
                 if (m1 == sym) {
                     continue;
@@ -2439,7 +2441,7 @@
             }
 
             //...check each method m2 that is a member of 'site'
-            for (Symbol m2 : types.membersClosure(site, false).getSymbolsByName(sym.name, cf)) {
+            for (Symbol m2 : symbolsByName) {
                 if (m2 == m1) continue;
                 //if (i) the signature of 'sym' is not a subsignature of m1 (seen as
                 //a member of 'site') and (ii) m1 has the same erasure as m2, issue an error