mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-28 07:14:30 +02:00
8245677
: Optimize lookups in empty HashMaps
Reviewed-by: jlaskey, redestad
This commit is contained in:
parent
e04e052889
commit
742d35e08a
2 changed files with 16 additions and 16 deletions
|
@ -438,7 +438,7 @@ public class LinkedHashMap<K,V>
|
|||
*/
|
||||
public V get(Object key) {
|
||||
Node<K,V> e;
|
||||
if ((e = getNode(hash(key), key)) == null)
|
||||
if ((e = getNode(key)) == null)
|
||||
return null;
|
||||
if (accessOrder)
|
||||
afterNodeAccess(e);
|
||||
|
@ -450,7 +450,7 @@ public class LinkedHashMap<K,V>
|
|||
*/
|
||||
public V getOrDefault(Object key, V defaultValue) {
|
||||
Node<K,V> e;
|
||||
if ((e = getNode(hash(key), key)) == null)
|
||||
if ((e = getNode(key)) == null)
|
||||
return defaultValue;
|
||||
if (accessOrder)
|
||||
afterNodeAccess(e);
|
||||
|
@ -685,7 +685,7 @@ public class LinkedHashMap<K,V>
|
|||
return false;
|
||||
Map.Entry<?,?> e = (Map.Entry<?,?>) o;
|
||||
Object key = e.getKey();
|
||||
Node<K,V> candidate = getNode(hash(key), key);
|
||||
Node<K,V> candidate = getNode(key);
|
||||
return candidate != null && candidate.equals(e);
|
||||
}
|
||||
public final boolean remove(Object o) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue