Performance improvement per Anthony Whitford in LANG-574. Check for isArray to short-circuit the 9 instanceof checks. Improves both non-arrays and Object[] in tests

git-svn-id: https://svn.apache.org/repos/asf/commons/proper/lang/trunk@897419 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Henri Yandell 2010-01-09 11:20:49 +00:00
parent 72e4ab4b00
commit 8d518b7786
1 changed files with 6 additions and 3 deletions

View File

@ -861,6 +861,8 @@ public class HashCodeBuilder {
iTotal = iTotal * iConstant;
} else {
Class clss = object.getClass();
if(clss.isArray()) {
// 'Switch' on type of array, to dispatch to the correct handler
// This handles multi dimensional arrays
if (object instanceof long[]) {
@ -879,12 +881,13 @@ public class HashCodeBuilder {
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;
}