mirror of
https://github.com/apache/commons-lang.git
synced 2025-03-06 16:09:22 +00:00
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:
parent
7fc38e82ec
commit
486740b60a
@ -855,11 +855,6 @@ public HashCodeBuilder append(Object object) {
|
||||
if (object == null) {
|
||||
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
|
||||
@ -879,10 +874,11 @@ public HashCodeBuilder append(Object object) {
|
||||
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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user