[r=Peter.Gromov] tolerate null key for get and containsKey

This commit is contained in:
Maxim.Mossienko
2013-01-18 16:41:50 +01:00
parent 906f1360c2
commit 06160d5555
@@ -185,7 +185,8 @@ abstract class RefHashMap<K, V> extends AbstractMap<K, V> implements Map<K, V> {
}
@Override
public boolean containsKey(@NotNull Object key) {
public boolean containsKey(Object key) {
if (key == null) return false;
// optimization:
myHardKeyInstance.set((K)key);
boolean result = myMap.containsKey(myHardKeyInstance);
@@ -194,7 +195,8 @@ abstract class RefHashMap<K, V> extends AbstractMap<K, V> implements Map<K, V> {
}
@Override
public V get(@NotNull Object key) {
public V get(Object key) {
if (key == null) return null;
myHardKeyInstance.set((K)key);
V result = myMap.get(myHardKeyInstance);
myHardKeyInstance.clear();