commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bay...@apache.org
Subject svn commit: r564070 - /commons/proper/lang/trunk/src/java/org/apache/commons/lang/builder/HashCodeBuilder.java
Date Thu, 09 Aug 2007 01:58:12 GMT
Author: bayard
Date: Wed Aug  8 18:58:11 2007
New Revision: 564070

URL: http://svn.apache.org/viewvc?view=rev&rev=564070
Log:
Altering the if/else logic of HashCodeBuilder.append(Object) as per LANG-345 to get 20->40%
speed improvements. This is because the code no longer uses Class.isArray() on every invocation.
Many thanks to Venkatesh Prasad Ranganath for offering this improvement. 

Modified:
    commons/proper/lang/trunk/src/java/org/apache/commons/lang/builder/HashCodeBuilder.java

Modified: commons/proper/lang/trunk/src/java/org/apache/commons/lang/builder/HashCodeBuilder.java
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/java/org/apache/commons/lang/builder/HashCodeBuilder.java?view=diff&rev=564070&r1=564069&r2=564070
==============================================================================
--- commons/proper/lang/trunk/src/java/org/apache/commons/lang/builder/HashCodeBuilder.java
(original)
+++ commons/proper/lang/trunk/src/java/org/apache/commons/lang/builder/HashCodeBuilder.java
Wed Aug  8 18:58:11 2007
@@ -856,11 +856,6 @@
             iTotal = iTotal * iConstant;
 
         } else {
-            if (object.getClass().isArray() == false) {
-                // the simple case, not an array, just the element
-                iTotal = iTotal * iConstant + object.hashCode();
-
-            } else {
                 // 'Switch' on type of array, to dispatch to the correct handler
                 // This handles multi dimensional arrays
                 if (object instanceof long[]) {
@@ -879,11 +874,12 @@
                     append((float[]) object);
                 } else if (object instanceof boolean[]) {
                     append((boolean[]) object);
-                } else {
+                } else if (object instanceof Object[]) {
                     // Not an array of primitives
                     append((Object[]) object);
+                } else {
+                    iTotal = iTotal * iConstant + object.hashCode();
                 }
-            }
         }
         return this;
     }



Mime
View raw message