changeset 31916:7e6f02d5ed41

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
author psandoz
date Fri, 24 Jul 2015 15:33:13 -0700
parents 6b8f19926871
children 7c00c692dd08
files jdk/src/java.base/share/classes/java/util/EnumMap.java
diffstat 1 files changed, 4 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- 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++) {