diff --git a/src/java/org/apache/commons/lang/math/DoubleRange.java b/src/java/org/apache/commons/lang/math/DoubleRange.java index 8c62075cd..cafa2949c 100644 --- a/src/java/org/apache/commons/lang/math/DoubleRange.java +++ b/src/java/org/apache/commons/lang/math/DoubleRange.java @@ -398,13 +398,15 @@ public final class DoubleRange extends Range implements Serializable { */ @Override public int hashCode() { - if (hashCode == 0) { - hashCode = 17; - hashCode = 37 * hashCode + getClass().hashCode(); + int temp = hashCode; + if (temp == 0) { + temp = 17; + temp = 37 * temp + getClass().hashCode(); long lng = Double.doubleToLongBits(min); - hashCode = 37 * hashCode + ((int) (lng ^ (lng >> 32))); + temp = 37 * temp + ((int) (lng ^ (lng >> 32))); lng = Double.doubleToLongBits(max); - hashCode = 37 * hashCode + ((int) (lng ^ (lng >> 32))); + temp = 37 * temp + ((int) (lng ^ (lng >> 32))); + hashCode = temp; } return hashCode; } diff --git a/src/java/org/apache/commons/lang/math/FloatRange.java b/src/java/org/apache/commons/lang/math/FloatRange.java index d22c7018e..4472aa620 100644 --- a/src/java/org/apache/commons/lang/math/FloatRange.java +++ b/src/java/org/apache/commons/lang/math/FloatRange.java @@ -394,11 +394,13 @@ public final class FloatRange extends Range implements Serializable { */ @Override public int hashCode() { - if (hashCode == 0) { - hashCode = 17; - hashCode = 37 * hashCode + getClass().hashCode(); - hashCode = 37 * hashCode + Float.floatToIntBits(min); - hashCode = 37 * hashCode + Float.floatToIntBits(max); + int temp = hashCode; + if (temp == 0) { + temp = 17; + temp = 37 * temp + getClass().hashCode(); + temp = 37 * temp + Float.floatToIntBits(min); + temp = 37 * temp + Float.floatToIntBits(max); + hashCode = temp; } return hashCode; } diff --git a/src/java/org/apache/commons/lang/math/IntRange.java b/src/java/org/apache/commons/lang/math/IntRange.java index fb5155d8d..e8b84ce65 100644 --- a/src/java/org/apache/commons/lang/math/IntRange.java +++ b/src/java/org/apache/commons/lang/math/IntRange.java @@ -368,11 +368,13 @@ public final class IntRange extends Range implements Serializable { */ @Override public int hashCode() { - if (hashCode == 0) { - hashCode = 17; - hashCode = 37 * hashCode + getClass().hashCode(); - hashCode = 37 * hashCode + min; - hashCode = 37 * hashCode + max; + int temp = hashCode; + if (temp == 0) { + temp = 17; + temp = 37 * temp + getClass().hashCode(); + temp = 37 * temp + min; + temp = 37 * temp + max; + hashCode = temp; } return hashCode; } diff --git a/src/java/org/apache/commons/lang/math/LongRange.java b/src/java/org/apache/commons/lang/math/LongRange.java index 971351522..51bd6c778 100644 --- a/src/java/org/apache/commons/lang/math/LongRange.java +++ b/src/java/org/apache/commons/lang/math/LongRange.java @@ -381,11 +381,13 @@ public final class LongRange extends Range implements Serializable { */ @Override public int hashCode() { - if (hashCode == 0) { - hashCode = 17; - hashCode = 37 * hashCode + getClass().hashCode(); - hashCode = 37 * hashCode + ((int) (min ^ (min >> 32))); - hashCode = 37 * hashCode + ((int) (max ^ (max >> 32))); + int temp = hashCode; + if (temp == 0) { + temp = 17; + temp = 37 * temp + getClass().hashCode(); + temp = 37 * temp + ((int) (min ^ (min >> 32))); + temp = 37 * temp + ((int) (max ^ (max >> 32))); + hashCode = temp; } return hashCode; } diff --git a/src/java/org/apache/commons/lang/math/NumberRange.java b/src/java/org/apache/commons/lang/math/NumberRange.java index f74a00cd5..beff6f8f3 100644 --- a/src/java/org/apache/commons/lang/math/NumberRange.java +++ b/src/java/org/apache/commons/lang/math/NumberRange.java @@ -215,11 +215,13 @@ public final class NumberRange extends Range implements Serializable { */ @Override public int hashCode() { - if (hashCode == 0) { - hashCode = 17; - hashCode = 37 * hashCode + getClass().hashCode(); - hashCode = 37 * hashCode + min.hashCode(); - hashCode = 37 * hashCode + max.hashCode(); + int temp = hashCode; + if (temp == 0) { + temp = 17; + temp = 37 * temp + getClass().hashCode(); + temp = 37 * temp + min.hashCode(); + temp = 37 * temp + max.hashCode(); + hashCode = temp; } return hashCode; }