DATACMNS-1366 - Performance improvements in mapping subsystem
We now use a presized HashMap and Weak references in BasicPersistentEntity to improve memory and CPU profile and and avoid unmodifiable collection creation in BasicPersistentEntity.iterator(). Refactored ClassTypeInformation.from(…) lambda to method reference and predefined collection size for the cache. Reduced object instantiations during TypeDiscoverer.equals(…) by checking for type variable map emptiness to avoid Map iterator creation in Map.equals(…). Original pull request: #305.
This commit is contained in:
committed by
Oliver Gierke
parent
e50e013964
commit
4600190d01
@@ -105,7 +105,7 @@ public class BasicPersistentEntity<T, P extends PersistentProperty<P>> implement
|
||||
this.constructor = PreferredConstructorDiscoverer.discover(this);
|
||||
this.associations = comparator == null ? new HashSet<>() : new TreeSet<>(new AssociationComparator<>(comparator));
|
||||
|
||||
this.propertyCache = new HashMap<>();
|
||||
this.propertyCache = new HashMap<>(16, 1f);
|
||||
this.annotationCache = new ConcurrentReferenceHashMap<>(16, ReferenceType.WEAK);
|
||||
this.propertyAnnotationCache = CollectionUtils
|
||||
.toMultiValueMap(new ConcurrentReferenceHashMap<>(16, ReferenceType.WEAK));
|
||||
@@ -507,7 +507,21 @@ public class BasicPersistentEntity<T, P extends PersistentProperty<P>> implement
|
||||
*/
|
||||
@Override
|
||||
public Iterator<P> iterator() {
|
||||
return Collections.unmodifiableList(properties).iterator();
|
||||
|
||||
Iterator<P> iterator = properties.iterator();
|
||||
|
||||
return new Iterator<P>() {
|
||||
|
||||
@Override
|
||||
public boolean hasNext() {
|
||||
return iterator.hasNext();
|
||||
}
|
||||
|
||||
@Override
|
||||
public P next() {
|
||||
return iterator.next();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
protected EvaluationContext getEvaluationContext(Object rootObject) {
|
||||
|
||||
Reference in New Issue
Block a user