minor change, for possibly better performance

This commit is contained in:
Gavin King 2025-01-01 22:40:22 +01:00
parent 8509166469
commit 05b8d0dbe9
1 changed files with 5 additions and 8 deletions

View File

@ -6,7 +6,6 @@ package org.hibernate.graph.internal;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.stream.Collectors;
import org.hibernate.graph.spi.AttributeNodeImplementor; import org.hibernate.graph.spi.AttributeNodeImplementor;
import org.hibernate.graph.spi.SubGraphImplementor; import org.hibernate.graph.spi.SubGraphImplementor;
@ -161,9 +160,9 @@ public class AttributeNodeImpl<J>
return null; return null;
} }
else { else {
return nodeMap.entrySet().stream() final HashMap<Class<? extends U>, SubGraphImplementor<? extends V>> map = new HashMap<>( nodeMap.size() );
.map(entry -> Map.entry( entry.getKey(), entry.getValue().makeCopy( mutable ) )) nodeMap.forEach( (attribute, subgraph) -> map.put( attribute, subgraph.makeCopy( mutable ) ) );
.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); return map;
} }
} }
@ -194,15 +193,13 @@ public class AttributeNodeImpl<J>
} }
private <T> SubGraphImplementor<T> getSubgraphForPut(SubGraphImplementor<T> subgraph) { private <T> SubGraphImplementor<T> getSubgraphForPut(SubGraphImplementor<T> subgraph) {
final SubGraphImplementor<T> existing;
if ( subgraphMap == null ) { if ( subgraphMap == null ) {
subgraphMap = new HashMap<>(); subgraphMap = new HashMap<>();
existing = null; return null;
} }
else { else {
existing = getSubgraph( subgraph.getClassType() ); return getSubgraph( subgraph.getClassType() );
} }
return existing;
} }
private <T> SubGraphImplementor<T> getKeySubgraphForPut(SubGraphImplementor<T> subgraph) { private <T> SubGraphImplementor<T> getKeySubgraphForPut(SubGraphImplementor<T> subgraph) {