8062849: Optimize EnumMap.equals
Summary: In the equals method, if the two EnumMaps are a different size return false since they can't be equal.
Reviewed-by: martin, bchristi, rriggs, psandoz
Contributed-by: steve.drach@oracle.com
--- a/jdk/src/java.base/share/classes/java/util/EnumMap.java Wed Jul 22 14:44:30 2015 -0700
+++ b/jdk/src/java.base/share/classes/java/util/EnumMap.java Fri Jul 24 15:33:13 2015 -0700
@@ -681,8 +681,11 @@
}
private boolean equals(EnumMap<?,?> em) {
+ if (em.size != size)
+ return false;
+
if (em.keyType != keyType)
- return size == 0 && em.size == 0;
+ return size == 0;
// Key types match, compare each value
for (int i = 0; i < keyUniverse.length; i++) {