commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nia...@apache.org
Subject svn commit: r905082 - /commons/proper/lang/branches/LANG_2_X/src/main/java/org/apache/commons/lang/builder/HashCodeBuilder.java
Date Sun, 31 Jan 2010 17:56:08 GMT
Author: niallp
Date: Sun Jan 31 17:56:08 2010
New Revision: 905082

URL: http://svn.apache.org/viewvc?rev=905082&view=rev
Log:
Port LANG-574 to 2.x branch - Performance improvement: check for isArray to short-circuit
the 9 instanceof checks. Improves both non-arrays and Object[] in tests

Modified:
    commons/proper/lang/branches/LANG_2_X/src/main/java/org/apache/commons/lang/builder/HashCodeBuilder.java

Modified: commons/proper/lang/branches/LANG_2_X/src/main/java/org/apache/commons/lang/builder/HashCodeBuilder.java
URL: http://svn.apache.org/viewvc/commons/proper/lang/branches/LANG_2_X/src/main/java/org/apache/commons/lang/builder/HashCodeBuilder.java?rev=905082&r1=905081&r2=905082&view=diff
==============================================================================
--- commons/proper/lang/branches/LANG_2_X/src/main/java/org/apache/commons/lang/builder/HashCodeBuilder.java
(original)
+++ commons/proper/lang/branches/LANG_2_X/src/main/java/org/apache/commons/lang/builder/HashCodeBuilder.java
Sun Jan 31 17:56:08 2010
@@ -860,6 +860,7 @@
             iTotal = iTotal * iConstant;
 
         } else {
+            if(object.getClass().isArray()) {
                 // 'Switch' on type of array, to dispatch to the correct handler
                 // This handles multi dimensional arrays
                 if (object instanceof long[]) {
@@ -878,12 +879,13 @@
                     append((float[]) object);
                 } else if (object instanceof boolean[]) {
                     append((boolean[]) object);
-                } else if (object instanceof Object[]) {
+                } else {
                     // Not an array of primitives
                     append((Object[]) object);
-                } else {
-                    iTotal = iTotal * iConstant + object.hashCode();
                 }
+            } else {
+                iTotal = iTotal * iConstant + object.hashCode();
+            }
         }
         return this;
     }



Mime
View raw message