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.

git-svn-id: https://svn.apache.org/repos/asf/commons/proper/lang/trunk@564070 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Henri Yandell 2007-08-09 01:58:11 +00:00
parent 7fc38e82ec
commit 486740b60a
1 changed files with 3 additions and 7 deletions

View File

@ -856,11 +856,6 @@ public class HashCodeBuilder {
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 @@ public class HashCodeBuilder {
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;
}