Skip to content

Commit cced717

Browse files
committed
minor change, for possibly better performance
1 parent eb45abe commit cced717

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

hibernate-core/src/main/java/org/hibernate/graph/internal/AttributeNodeImpl.java

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66

77
import java.util.HashMap;
88
import java.util.Map;
9-
import java.util.stream.Collectors;
109

1110
import org.hibernate.graph.spi.AttributeNodeImplementor;
1211
import org.hibernate.graph.spi.SubGraphImplementor;
@@ -161,9 +160,9 @@ private <U,V> Map<Class<? extends U>, SubGraphImplementor<? extends V>> makeMapC
161160
return null;
162161
}
163162
else {
164-
return nodeMap.entrySet().stream()
165-
.map(entry -> Map.entry( entry.getKey(), entry.getValue().makeCopy( mutable ) ))
166-
.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
163+
final HashMap<Class<? extends U>, SubGraphImplementor<? extends V>> map = new HashMap<>( nodeMap.size() );
164+
nodeMap.forEach( (attribute, subgraph) -> map.put( attribute, subgraph.makeCopy( mutable ) ) );
165+
return map;
167166
}
168167
}
169168

@@ -194,15 +193,13 @@ private <T> void mergeToSubgraph(SubGraphImplementor<T> subgraph) {
194193
}
195194

196195
private <T> SubGraphImplementor<T> getSubgraphForPut(SubGraphImplementor<T> subgraph) {
197-
final SubGraphImplementor<T> existing;
198196
if ( subgraphMap == null ) {
199197
subgraphMap = new HashMap<>();
200-
existing = null;
198+
return null;
201199
}
202200
else {
203-
existing = getSubgraph( subgraph.getClassType() );
201+
return getSubgraph( subgraph.getClassType() );
204202
}
205-
return existing;
206203
}
207204

208205
private <T> SubGraphImplementor<T> getKeySubgraphForPut(SubGraphImplementor<T> subgraph) {

0 commit comments

Comments
 (0)