improve hashcodes: LUCENE-460

git-svn-id: https://svn.apache.org/repos/asf/lucene/java/trunk@358693 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Yonik Seeley 2005-12-23 03:37:50 +00:00
parent 99c9289a89
commit 75c81da538
1 changed files with 8 additions and 4 deletions

View File

@ -155,9 +155,13 @@ public class RangeQuery extends Query
/** Returns a hash code value for this object.*/
public int hashCode() {
return Float.floatToIntBits(getBoost()) ^
(lowerTerm != null ? lowerTerm.hashCode() : 0) ^
(upperTerm != null ? upperTerm.hashCode() : 0) ^
(this.inclusive ? 1 : 0);
int h = Float.floatToIntBits(getBoost());
h ^= lowerTerm != null ? lowerTerm.hashCode() : 0;
// reversible mix to make lower and upper position dependent and
// to prevent them from cancelling out.
h ^= (h << 25) | (h >>> 8);
h ^= upperTerm != null ? upperTerm.hashCode() : 0;
h ^= this.inclusive ? 0x2742E74A : 0;
return h;
}
}