-
Notifications
You must be signed in to change notification settings - Fork 13k
Closed
Labels
polishingImprove a implementation code or doc without change in current behavior/contentImprove a implementation code or doc without change in current behavior/content
Milestone
Description
| return map.computeIfAbsent(key, mappingFunction::apply); |
Present version
public static <K, V> V computeIfAbsent(Map<K, V> map, K key, Function<K, V> mappingFunction) {
V value = map.get(key);
if (value != null) {
return value;
}
return map.computeIfAbsent(key, mappingFunction::apply); // Object repeated creation
}Fix
public static <K, V> V computeIfAbsent(Map<K, V> map, K key, Function<K, V> mappingFunction) {
V value = map.get(key);
if (value != null) {
return value;
}
return map.computeIfAbsent(key, mappingFunction); // Pass parameters directly
}Metadata
Metadata
Assignees
Labels
polishingImprove a implementation code or doc without change in current behavior/contentImprove a implementation code or doc without change in current behavior/content