Skip to content

Commit 917fca4

Browse files
committed
Use HashMap instead of List ClassEntry.methods
1 parent 45a156d commit 917fca4

File tree

1 file changed

+8
-9
lines changed
  • substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/debugentry

1 file changed

+8
-9
lines changed

substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/debugentry/ClassEntry.java

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ public class ClassEntry extends StructureTypeEntry {
5959
/**
6060
* Details of methods located in this instance.
6161
*/
62-
protected List<MethodEntry> methods;
62+
protected Map<String, MethodEntry> methods;
6363
/**
6464
* A list recording details of all primary ranges included in this class sorted by ascending
6565
* address range.
@@ -94,7 +94,7 @@ public ClassEntry(String className, FileEntry fileEntry, int size) {
9494
super(className, size);
9595
this.interfaces = new LinkedList<>();
9696
this.fileEntry = fileEntry;
97-
this.methods = new LinkedList<>();
97+
this.methods = new HashMap<>();
9898
this.primaryEntries = new LinkedList<>();
9999
this.primaryIndex = new HashMap<>();
100100
this.localFiles = new LinkedList<>();
@@ -295,7 +295,8 @@ protected MethodEntry processMethod(DebugMethodInfo debugMethodInfo, DebugInfoBa
295295
*/
296296
FileEntry methodFileEntry = debugInfoBase.ensureFileEntry(fileName, filePath, cachePath);
297297
final MethodEntry methodEntry = new MethodEntry(methodFileEntry, methodName, this, resultType, paramTypeArray, paramNameArray, modifiers, debugMethodInfo.isDeoptTarget());
298-
methods.add(methodEntry);
298+
String key = methodName + debugMethodInfo.paramSignature() + resultTypeName;
299+
methods.put(key, methodEntry);
299300
return methodEntry;
300301
}
301302

@@ -350,12 +351,10 @@ public MethodEntry ensureMethodEntry(DebugMethodInfo debugMethodInfo, DebugInfoB
350351
String methodName = debugInfoBase.uniqueDebugString(debugMethodInfo.name());
351352
String paramSignature = debugMethodInfo.paramSignature();
352353
String returnTypeName = debugMethodInfo.valueType();
353-
// TODO improve data structure to avoid loops...
354-
for (MethodEntry methodEntry : methods) {
355-
if (methodEntry.match(methodName, paramSignature, returnTypeName)) {
356-
return methodEntry;
357-
}
354+
MethodEntry methodEntry = methods.get(methodName + paramSignature + returnTypeName);
355+
if (methodEntry == null) {
356+
methodEntry = processMethod(debugMethodInfo, debugInfoBase, debugContext);
358357
}
359-
return processMethod(debugMethodInfo, debugInfoBase, debugContext);
358+
return methodEntry;
360359
}
361360
}

0 commit comments

Comments
 (0)