use Math.max rather than an if statement
This commit is contained in:
parent
59588913b3
commit
fcfc41209b
|
@ -297,10 +297,7 @@ public abstract class DecayFunctionParser implements ScoreFunctionParser {
|
||||||
GeoPoint other = getValue(docId, origin);
|
GeoPoint other = getValue(docId, origin);
|
||||||
double distance = Math.abs(distFunction.calculate(origin.lat(), origin.lon(), other.lat(), other.lon(),
|
double distance = Math.abs(distFunction.calculate(origin.lat(), origin.lon(), other.lat(), other.lon(),
|
||||||
DistanceUnit.METERS)) - offset;
|
DistanceUnit.METERS)) - offset;
|
||||||
if (distance < 0.0d) {
|
return Math.max(0.0d, distance);
|
||||||
distance = 0.0d;
|
|
||||||
}
|
|
||||||
return distance;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -345,10 +342,7 @@ public abstract class DecayFunctionParser implements ScoreFunctionParser {
|
||||||
@Override
|
@Override
|
||||||
protected double distance(int docId) {
|
protected double distance(int docId) {
|
||||||
double distance = Math.abs(getValue(docId, origin) - origin) - offset;
|
double distance = Math.abs(getValue(docId, origin) - origin) - offset;
|
||||||
if (distance < 0.0) {
|
return Math.max(0.0d, distance);
|
||||||
distance = 0.0;
|
|
||||||
}
|
|
||||||
return distance;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in New Issue