mirror of https://github.com/apache/lucene.git
=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:
parent
5c052874e8
commit
5e5ed64b54
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue