COLLECTIONS-602: Improve efficiency of DefaultedMap.get. Applying patch provided by John Mark.
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/collections/trunk@1796031 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
9f0d58985f
commit
8f346f9f12
|
@ -21,6 +21,9 @@
|
|||
</properties>
|
||||
<body>
|
||||
<release version="4.2" date="YYYY-MM-DD" description="New features">
|
||||
<action issue="COLLECTIONS-602" dev="kinow" type="update" due-to="John Mark">
|
||||
Improve efficiency of DefaultedMap.get
|
||||
</action>
|
||||
<action issue="COLLECTIONS-603" dev="kinow" type="fix" due-to="Artem Konovalov">
|
||||
Small improvements for generics, conditional statements, and warnings suppressions.
|
||||
</action>
|
||||
|
|
|
@ -198,11 +198,10 @@ public class DefaultedMap<K, V> extends AbstractMapDecorator<K, V> implements Se
|
|||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public V get(final Object key) {
|
||||
// create value for key if key is not currently in the map
|
||||
if (map.containsKey(key) == false) {
|
||||
return value.transform((K) key);
|
||||
}
|
||||
return map.get(key);
|
||||
V v;
|
||||
return (((v = map.get(key)) != null) || map.containsKey(key))
|
||||
? v
|
||||
: value.transform((K) key);
|
||||
}
|
||||
|
||||
// no need to wrap keySet, entrySet or values as they are views of
|
||||
|
|
Loading…
Reference in New Issue