2828
2929import com .oracle .objectfile .debuginfo .DebugInfoProvider .DebugRangeInfo ;
3030
31+ import java .util .Arrays ;
32+ import java .util .stream .Collectors ;
33+
3134public class MethodEntry extends MemberEntry implements Comparable <MethodEntry > {
3235 final TypeEntry [] paramTypes ;
3336 final String [] paramNames ;
3437 public final boolean isDeoptTarget ;
3538 boolean isInRange ;
3639
3740 final String symbolName ;
41+ private String signature ;
3842
3943 public MethodEntry (FileEntry fileEntry , String symbolName , String methodName , ClassEntry ownerType ,
4044 TypeEntry valueType , TypeEntry [] paramTypes , String [] paramNames , int modifiers ,
@@ -120,6 +124,13 @@ public String getSymbolName() {
120124 return symbolName ;
121125 }
122126
127+ private String getSignature () {
128+ if (signature == null ) {
129+ signature = Arrays .stream (paramTypes ).map (TypeEntry ::getTypeName ).collect (Collectors .joining (", " ));
130+ }
131+ return signature ;
132+ }
133+
123134 public int compareTo (String methodName , String paramSignature , String returnTypeName ) {
124135 int nameComparison = memberName .compareTo (methodName );
125136 if (nameComparison != 0 ) {
@@ -129,24 +140,7 @@ public int compareTo(String methodName, String paramSignature, String returnType
129140 if (typeComparison != 0 ) {
130141 return typeComparison ;
131142 }
132- String [] paramTypeNames = paramSignature .split (("," ));
133- int length ;
134- if (paramSignature .trim ().length () == 0 ) {
135- length = 0 ;
136- } else {
137- length = paramTypeNames .length ;
138- }
139- int paramCountComparison = getParamCount () - length ;
140- if (paramCountComparison != 0 ) {
141- return paramCountComparison ;
142- }
143- for (int i = 0 ; i < getParamCount (); i ++) {
144- int paraComparison = getParamTypeName (i ).compareTo (paramTypeNames [i ].trim ());
145- if (paraComparison != 0 ) {
146- return paraComparison ;
147- }
148- }
149- return 0 ;
143+ return getSignature ().compareTo (paramSignature );
150144 }
151145
152146 @ Override
@@ -160,16 +154,6 @@ public int compareTo(MethodEntry other) {
160154 if (typeComparison != 0 ) {
161155 return typeComparison ;
162156 }
163- int paramCountComparison = getParamCount () - other .getParamCount ();
164- if (paramCountComparison != 0 ) {
165- return paramCountComparison ;
166- }
167- for (int i = 0 ; i < getParamCount (); i ++) {
168- int paramComparison = getParamTypeName (i ).compareTo (other .getParamTypeName (i ));
169- if (paramComparison != 0 ) {
170- return paramComparison ;
171- }
172- }
173- return 0 ;
157+ return getSignature ().compareTo (other .getSignature ());
174158 }
175159}
0 commit comments