RFR 8170733: HashMap.HashIterator.remove method does not use cached value for the hash code.
Paul Sandoz
paul.sandoz at oracle.com
Mon Dec 5 20:12:39 UTC 2016
Hi,
Please review this small fix to the Linked/HashMap iterators. The remove method can use the cached hash code.
Paul.
diff -r 5c9389804cbc src/java.base/share/classes/java/util/HashMap.java
--- a/src/java.base/share/classes/java/util/HashMap.java Mon Dec 05 12:53:53 2016 +0530
+++ b/src/java.base/share/classes/java/util/HashMap.java Mon Dec 05 12:10:46 2016 -0800
@@ -1502,8 +1502,7 @@
if (modCount != expectedModCount)
throw new ConcurrentModificationException();
current = null;
- K key = p.key;
- removeNode(hash(key), key, null, false, false);
+ removeNode(p.hash, p.key, null, false, false);
expectedModCount = modCount;
}
}
diff -r 5c9389804cbc src/java.base/share/classes/java/util/LinkedHashMap.java
--- a/src/java.base/share/classes/java/util/LinkedHashMap.java Mon Dec 05 12:53:53 2016 +0530
+++ b/src/java.base/share/classes/java/util/LinkedHashMap.java Mon Dec 05 12:10:46 2016 -0800
@@ -731,8 +731,7 @@
if (modCount != expectedModCount)
throw new ConcurrentModificationException();
current = null;
- K key = p.key;
- removeNode(hash(key), key, null, false, false);
+ removeNode(p.hash, p.key, null, false, false);
expectedModCount = modCount;
}
}
More information about the core-libs-dev
mailing list