Apache Lucene open-source search software
improve hashcodes: LUCENE-460
Yonik Seeley75c81da538df
diff --git a/src/java/org/apache/lucene/search/RangeQuery.java b/src/java/org/apache/lucene/search/RangeQuery.javaindex f360a10876f..43b66b0e890 100644--- a/src/java/org/apache/lucene/search/RangeQuery.java+++ b/src/java/org/apache/lucene/search/RangeQuery.java@@ -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;}}