8245677: Optimize lookups in empty HashMaps

Reviewed-by: jlaskey, redestad
This commit is contained in:
Christoph Dreis 2020-05-25 22:21:45 +02:00 committed by Claes Redestad
parent e04e052889
commit 742d35e08a
2 changed files with 16 additions and 16 deletions

View file

@ -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) {