8334437: De-duplicate ProxyMethod list creation

Reviewed-by: asotona, liach
This commit is contained in:
Claes Redestad 2024-06-26 14:46:17 +00:00
parent 8591eff78d
commit 5883a20b82

View File

@ -508,8 +508,7 @@ final class ProxyGenerator {
Class<?>[] exceptionTypes = m.getSharedExceptionTypes(); Class<?>[] exceptionTypes = m.getSharedExceptionTypes();
String sig = m.toShortSignature(); String sig = m.toShortSignature();
List<ProxyMethod> sigmethods = proxyMethods.computeIfAbsent(sig, List<ProxyMethod> sigmethods = proxyMethodsFor(sig);
_ -> new ArrayList<>(3));
for (ProxyMethod pm : sigmethods) { for (ProxyMethod pm : sigmethods) {
if (returnType == pm.returnType) { if (returnType == pm.returnType) {
/* /*
@ -531,16 +530,17 @@ final class ProxyGenerator {
exceptionTypes, fromClass, "m" + proxyMethodCount++)); exceptionTypes, fromClass, "m" + proxyMethodCount++));
} }
private List<ProxyMethod> proxyMethodsFor(String sig) {
return proxyMethods.computeIfAbsent(sig, _ -> new ArrayList<>(3));
}
/** /**
* Add an existing ProxyMethod (hashcode, equals, toString). * Add an existing ProxyMethod (hashcode, equals, toString).
* *
* @param pm an existing ProxyMethod * @param pm an existing ProxyMethod
*/ */
private void addProxyMethod(ProxyMethod pm) { private void addProxyMethod(ProxyMethod pm) {
String sig = pm.shortSignature; proxyMethodsFor(pm.shortSignature).add(pm);
List<ProxyMethod> sigmethods = proxyMethods.computeIfAbsent(sig,
_ -> new ArrayList<>(3));
sigmethods.add(pm);
} }
/** /**