mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-04-19 03:01:48 +08:00
Merge pull request #2594 from youzipi/v5-dev
refactor(core:MapUtil): simplify code
This commit is contained in:
commit
4b49e6ccd6
@ -509,13 +509,7 @@ public class MapUtil {
|
||||
return map;
|
||||
}
|
||||
for (final Map.Entry<K, V> pair : entries) {
|
||||
final List<V> values;
|
||||
if (map.containsKey(pair.getKey())) {
|
||||
values = map.get(pair.getKey());
|
||||
} else {
|
||||
values = new ArrayList<>();
|
||||
map.put(pair.getKey(), values);
|
||||
}
|
||||
final List<V> values = map.computeIfAbsent(pair.getKey(), k -> new ArrayList<>());
|
||||
values.add(pair.getValue());
|
||||
}
|
||||
return map;
|
||||
|
Loading…
x
Reference in New Issue
Block a user