summaryrefslogtreecommitdiffstats
path: root/luni/src/main/java/java/util/HashMap.java
diff options
context:
space:
mode:
Diffstat (limited to 'luni/src/main/java/java/util/HashMap.java')
-rw-r--r--luni/src/main/java/java/util/HashMap.java33
1 files changed, 7 insertions, 26 deletions
diff --git a/luni/src/main/java/java/util/HashMap.java b/luni/src/main/java/java/util/HashMap.java
index 80fbd0c..b6fe646 100644
--- a/luni/src/main/java/java/util/HashMap.java
+++ b/luni/src/main/java/java/util/HashMap.java
@@ -297,12 +297,7 @@ public class HashMap<K, V> extends AbstractMap<K, V> implements Cloneable, Seria
return e == null ? null : e.value;
}
- // Doug Lea's supplemental secondaryHash function (inlined).
- // Replace with Collections.secondaryHash when the VM is fast enough (http://b/8290590).
- int hash = key.hashCode();
- hash ^= (hash >>> 20) ^ (hash >>> 12);
- hash ^= (hash >>> 7) ^ (hash >>> 4);
-
+ int hash = Collections.secondaryHash(key);
HashMapEntry<K, V>[] tab = table;
for (HashMapEntry<K, V> e = tab[hash & (tab.length - 1)];
e != null; e = e.next) {
@@ -327,12 +322,7 @@ public class HashMap<K, V> extends AbstractMap<K, V> implements Cloneable, Seria
return entryForNullKey != null;
}
- // Doug Lea's supplemental secondaryHash function (inlined).
- // Replace with Collections.secondaryHash when the VM is fast enough (http://b/8290590).
- int hash = key.hashCode();
- hash ^= (hash >>> 20) ^ (hash >>> 12);
- hash ^= (hash >>> 7) ^ (hash >>> 4);
-
+ int hash = Collections.secondaryHash(key);
HashMapEntry<K, V>[] tab = table;
for (HashMapEntry<K, V> e = tab[hash & (tab.length - 1)];
e != null; e = e.next) {
@@ -344,15 +334,6 @@ public class HashMap<K, V> extends AbstractMap<K, V> implements Cloneable, Seria
return false;
}
- // Doug Lea's supplemental secondaryHash function (non-inlined).
- // Replace with Collections.secondaryHash when the VM is fast enough (http://b/8290590).
- static int secondaryHash(Object key) {
- int hash = key.hashCode();
- hash ^= (hash >>> 20) ^ (hash >>> 12);
- hash ^= (hash >>> 7) ^ (hash >>> 4);
- return hash;
- }
-
/**
* Returns whether this map contains the specified value.
*
@@ -401,7 +382,7 @@ public class HashMap<K, V> extends AbstractMap<K, V> implements Cloneable, Seria
return putValueForNullKey(value);
}
- int hash = secondaryHash(key);
+ int hash = Collections.secondaryHash(key);
HashMapEntry<K, V>[] tab = table;
int index = hash & (tab.length - 1);
for (HashMapEntry<K, V> e = tab[index]; e != null; e = e.next) {
@@ -464,7 +445,7 @@ public class HashMap<K, V> extends AbstractMap<K, V> implements Cloneable, Seria
return;
}
- int hash = secondaryHash(key);
+ int hash = Collections.secondaryHash(key);
HashMapEntry<K, V>[] tab = table;
int index = hash & (tab.length - 1);
HashMapEntry<K, V> first = tab[index];
@@ -632,7 +613,7 @@ public class HashMap<K, V> extends AbstractMap<K, V> implements Cloneable, Seria
if (key == null) {
return removeNullKey();
}
- int hash = secondaryHash(key);
+ int hash = Collections.secondaryHash(key);
HashMapEntry<K, V>[] tab = table;
int index = hash & (tab.length - 1);
for (HashMapEntry<K, V> e = tab[index], prev = null;
@@ -852,7 +833,7 @@ public class HashMap<K, V> extends AbstractMap<K, V> implements Cloneable, Seria
return e != null && Objects.equal(value, e.value);
}
- int hash = secondaryHash(key);
+ int hash = Collections.secondaryHash(key);
HashMapEntry<K, V>[] tab = table;
int index = hash & (tab.length - 1);
for (HashMapEntry<K, V> e = tab[index]; e != null; e = e.next) {
@@ -880,7 +861,7 @@ public class HashMap<K, V> extends AbstractMap<K, V> implements Cloneable, Seria
return true;
}
- int hash = secondaryHash(key);
+ int hash = Collections.secondaryHash(key);
HashMapEntry<K, V>[] tab = table;
int index = hash & (tab.length - 1);
for (HashMapEntry<K, V> e = tab[index], prev = null;