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:
Oliver Gierke
2013-05-23 18:56:55 +02:00
parent 905565cbcc
commit cd2ea03928
5 changed files with 29 additions and 13 deletions

View File

@@ -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;
}
/*

View File

@@ -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;
}
/*