=SOLR-4911, small efficiency improvement, thanks Yogi.

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1491454 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Erick Erickson 2013-06-10 13:55:41 +00:00
parent 5c052874e8
commit 5e5ed64b54
2 changed files with 8 additions and 18 deletions

View File

@ -27,23 +27,18 @@ public class MaxFloatFunction extends MultiFloatFunction {
public MaxFloatFunction(ValueSource[] sources) {
super(sources);
}
@Override
@Override
protected String name() {
return "max";
}
@Override
protected float func(int doc, FunctionValues[] valsArr) {
boolean first = true;
float val = 0.0f;
if (valsArr.length == 0) return 0.0f;
float val = Float.NEGATIVE_INFINITY;
for (FunctionValues vals : valsArr) {
if (first) {
first = false;
val = vals.floatVal(doc);
} else {
val = Math.max(vals.floatVal(doc),val);
}
val = Math.max(vals.floatVal(doc), val);
}
return val;
}

View File

@ -35,15 +35,10 @@ public class MinFloatFunction extends MultiFloatFunction {
@Override
protected float func(int doc, FunctionValues[] valsArr) {
boolean first = true;
float val = 0.0f;
if (valsArr.length == 0) return 0.0f;
float val = Float.POSITIVE_INFINITY;
for (FunctionValues vals : valsArr) {
if (first) {
first = false;
val = vals.floatVal(doc);
} else {
val = Math.min(vals.floatVal(doc),val);
}
val = Math.min(vals.floatVal(doc), val);
}
return val;
}