mirror of
https://github.com/apache/commons-lang.git
synced 2025-02-27 20:49:07 +00:00
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:
parent
72e4ab4b00
commit
8d518b7786
@ -861,6 +861,8 @@ public HashCodeBuilder append(Object object) {
|
||||
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 HashCodeBuilder append(Object object) {
|
||||
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;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user