diff options
author | Simeon Andreev | 2019-02-28 15:25:00 +0000 |
---|---|---|
committer | Andrey Loskutov | 2019-03-16 16:26:40 +0000 |
commit | b9957bd06da31c58841b8ad50731877e58c32071 (patch) | |
tree | cb3f3fdafcec734112662424f79d79f492778e5d | |
parent | 1a97faeae1fab88b811216221e44c4b5a3bf3f33 (diff) | |
download | eclipse.jdt.core-b9957bd06da31c58841b8ad50731877e58c32071.tar.gz eclipse.jdt.core-b9957bd06da31c58841b8ad50731877e58c32071.tar.xz eclipse.jdt.core-b9957bd06da31c58841b8ad50731877e58c32071.zip |
Bug 544921 - CompilationUnitStructureRequestor has poor performanceI20190318-1800
CompilationUnitStructureRequestor.resolveDuplicates has poor performance
in extremely large source files with many field definitions. In
particular the class uses Eclipse custom hash maps, which show worse
performance than Java hash maps.
This change switches the two hash maps which show poor performance to
JRE hash maps.
Change-Id: I084232a59c8330769081bd7bdbaa8a3d5e35d5b9
Signed-off-by: Simeon Andreev <simeon.danailov.andreev@gmail.com>
-rw-r--r-- | org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CompilationUnitStructureRequestor.java | 27 |
1 files changed, 13 insertions, 14 deletions
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CompilationUnitStructureRequestor.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CompilationUnitStructureRequestor.java index 939c5c9b82..1e1b978a26 100644 --- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CompilationUnitStructureRequestor.java +++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CompilationUnitStructureRequestor.java @@ -48,7 +48,6 @@ import org.eclipse.jdt.internal.compiler.ast.UnaryExpression; import org.eclipse.jdt.internal.compiler.parser.Parser; import org.eclipse.jdt.internal.compiler.parser.RecoveryScanner; import org.eclipse.jdt.internal.compiler.util.HashtableOfObject; -import org.eclipse.jdt.internal.compiler.util.HashtableOfObjectToInt; import org.eclipse.jdt.internal.core.util.ReferenceInfoAdapter; import org.eclipse.jdt.internal.core.util.Util; /** @@ -84,13 +83,13 @@ public class CompilationUnitStructureRequestor extends ReferenceInfoAdapter impl /* * A table from a handle (with occurenceCount == 1) to the current occurence count for this handle */ - private HashtableOfObjectToInt occurenceCounts; + private HashMap<Object, Integer> occurenceCounts; /* * A table to store the occurrence count of anonymous types. The key will be the handle to the * enclosing type of the anonymous. */ - private HashtableOfObjectToInt localOccurrenceCounts; + private HashMap<Object, Integer> localOccurrenceCounts; /** * Stack of parent scope info objects. The info on the @@ -138,8 +137,8 @@ protected CompilationUnitStructureRequestor(ICompilationUnit unit, CompilationUn this.unit = unit; this.unitInfo = unitInfo; this.newElements = newElements; - this.occurenceCounts = new HashtableOfObjectToInt(); - this.localOccurrenceCounts = new HashtableOfObjectToInt(5); + this.occurenceCounts = new HashMap<>(); + this.localOccurrenceCounts = new HashMap<>(5); } /** * @see ISourceElementRequestor @@ -794,12 +793,12 @@ public void exitType(int declarationEnd) { * of the handle being created. */ protected void resolveDuplicates(SourceRefElement handle) { - int occurenceCount = this.occurenceCounts.get(handle); - if (occurenceCount == -1) - this.occurenceCounts.put(handle, 1); + Integer occurenceCount = this.occurenceCounts.get(handle); + if (occurenceCount == null) + this.occurenceCounts.put(handle, Integer.valueOf(1)); else { - this.occurenceCounts.put(handle, ++occurenceCount); - handle.occurrenceCount = occurenceCount; + this.occurenceCounts.put(handle, Integer.valueOf(occurenceCount.intValue() + 1)); + handle.occurrenceCount = occurenceCount.intValue() + 1; } // https://bugs.eclipse.org/bugs/show_bug.cgi?id=342393 @@ -808,11 +807,11 @@ protected void resolveDuplicates(SourceRefElement handle) { if (handle instanceof SourceType && ((SourceType) handle).isAnonymous()) { Object key = handle.getParent().getAncestor(IJavaElement.TYPE); occurenceCount = this.localOccurrenceCounts.get(key); - if (occurenceCount == -1) - this.localOccurrenceCounts.put(key, 1); + if (occurenceCount == null) + this.localOccurrenceCounts.put(key, Integer.valueOf(1)); else { - this.localOccurrenceCounts.put(key, ++occurenceCount); - ((SourceType)handle).localOccurrenceCount = occurenceCount; + this.localOccurrenceCounts.put(key, Integer.valueOf(occurenceCount.intValue() + 1)); + ((SourceType)handle).localOccurrenceCount = occurenceCount.intValue() + 1; } } } |