Skip to content

Commit

Permalink
COLLECTIONS-602: Improve efficiency of DefaultedMap.get. Applying pat…
Browse files Browse the repository at this point in the history
…ch provided by John Mark.

git-svn-id: https://svn.apache.org/repos/asf/commons/proper/collections/trunk@1796031 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
kinow committed May 24, 2017
1 parent 9f0d589 commit 8f346f9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
3 changes: 3 additions & 0 deletions src/changes/changes.xml
Expand Up @@ -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>
Expand Down
Expand Up @@ -198,11 +198,10 @@ private void readObject(final ObjectInputStream in) throws IOException, ClassNot
@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
Expand Down

0 comments on commit 8f346f9

Please sign in to comment.