DATACMNS-332 - Further performance improvements.
Reverted from ConcurrentHashMap to plain HashMap where concurrency wasn't an issue and profiling showed performance hotspots. Introduced caches for ParameterizedTypeInformation.getComponentType() and the resolved raw type in TypeDiscoverer.
This commit is contained in:
@@ -35,6 +35,7 @@ import org.springframework.core.GenericTypeResolver;
|
||||
class ParameterizedTypeInformation<T> extends ParentTypeAwareTypeInformation<T> {
|
||||
|
||||
private final ParameterizedType type;
|
||||
private TypeInformation<?> componentType;
|
||||
|
||||
/**
|
||||
* Creates a new {@link ParameterizedTypeInformation} for the given {@link Type} and parent {@link TypeDiscoverer}.
|
||||
@@ -136,7 +137,12 @@ class ParameterizedTypeInformation<T> extends ParentTypeAwareTypeInformation<T>
|
||||
*/
|
||||
@Override
|
||||
public TypeInformation<?> getComponentType() {
|
||||
return createInfo(type.getActualTypeArguments()[0]);
|
||||
|
||||
if (componentType == null) {
|
||||
this.componentType = createInfo(type.getActualTypeArguments()[0]);
|
||||
}
|
||||
|
||||
return this.componentType;
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -51,6 +51,8 @@ class TypeDiscoverer<S> implements TypeInformation<S> {
|
||||
private final Map<TypeVariable, Type> typeVariableMap;
|
||||
private final Map<String, TypeInformation<?>> fieldTypes = new ConcurrentHashMap<String, TypeInformation<?>>();
|
||||
|
||||
private Class<S> resolvedType;
|
||||
|
||||
/**
|
||||
* Creates a ne {@link TypeDiscoverer} for the given type, type variable map and parent.
|
||||
*
|
||||
@@ -261,7 +263,12 @@ class TypeDiscoverer<S> implements TypeInformation<S> {
|
||||
* @see org.springframework.data.util.TypeInformation#getType()
|
||||
*/
|
||||
public Class<S> getType() {
|
||||
return resolveType(type);
|
||||
|
||||
if (resolvedType == null) {
|
||||
this.resolvedType = resolveType(type);
|
||||
}
|
||||
|
||||
return this.resolvedType;
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
Reference in New Issue
Block a user