7122740: PropertyDescriptor Performance Slow
Reviewed-by: rupashka
This commit is contained in:
parent
30f7f59109
commit
e20614ed03
@ -154,7 +154,7 @@ public final class TypeResolver {
|
|||||||
* @see #resolve(Type)
|
* @see #resolve(Type)
|
||||||
*/
|
*/
|
||||||
public static Type resolve(Type actual, Type formal) {
|
public static Type resolve(Type actual, Type formal) {
|
||||||
return new TypeResolver(actual).resolve(formal);
|
return getTypeResolver(actual).resolve(formal);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -169,7 +169,7 @@ public final class TypeResolver {
|
|||||||
* @see #resolve(Type[])
|
* @see #resolve(Type[])
|
||||||
*/
|
*/
|
||||||
public static Type[] resolve(Type actual, Type[] formals) {
|
public static Type[] resolve(Type actual, Type[] formals) {
|
||||||
return new TypeResolver(actual).resolve(formals);
|
return getTypeResolver(actual).resolve(formals);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -228,9 +228,20 @@ public final class TypeResolver {
|
|||||||
return classes;
|
return classes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static TypeResolver getTypeResolver(Type type) {
|
||||||
|
synchronized (CACHE) {
|
||||||
|
TypeResolver resolver = CACHE.get(type);
|
||||||
|
if (resolver == null) {
|
||||||
|
resolver = new TypeResolver(type);
|
||||||
|
CACHE.put(type, resolver);
|
||||||
|
}
|
||||||
|
return resolver;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private final Map<TypeVariable<?>, Type> map
|
private static final WeakCache<Type, TypeResolver> CACHE = new WeakCache<>();
|
||||||
= new HashMap<TypeVariable<?>, Type>();
|
|
||||||
|
private final Map<TypeVariable<?>, Type> map = new HashMap<>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs the type resolver for the given actual type.
|
* Constructs the type resolver for the given actual type.
|
||||||
|
Loading…
Reference in New Issue
Block a user