use Math.max rather than an if statement

This commit is contained in:
Simon Willnauer 2013-10-31 14:36:24 +01:00
parent 59588913b3
commit fcfc41209b
1 changed files with 2 additions and 8 deletions

View File

@ -297,10 +297,7 @@ public abstract class DecayFunctionParser implements ScoreFunctionParser {
GeoPoint other = getValue(docId, origin);
double distance = Math.abs(distFunction.calculate(origin.lat(), origin.lon(), other.lat(), other.lon(),
DistanceUnit.METERS)) - offset;
if (distance < 0.0d) {
distance = 0.0d;
}
return distance;
return Math.max(0.0d, distance);
}
@Override
@ -345,10 +342,7 @@ public abstract class DecayFunctionParser implements ScoreFunctionParser {
@Override
protected double distance(int docId) {
double distance = Math.abs(getValue(docId, origin) - origin) - offset;
if (distance < 0.0) {
distance = 0.0;
}
return distance;
return Math.max(0.0d, distance);
}
@Override