diff -r 9730379d57a7 lucene/src/java/org/apache/lucene/search/DisjunctionMaxScorer.java --- a/lucene/src/java/org/apache/lucene/search/DisjunctionMaxScorer.java Sun Oct 10 14:20:56 2010 -0400 +++ b/lucene/src/java/org/apache/lucene/search/DisjunctionMaxScorer.java Mon Oct 11 09:15:38 2010 -0400 @@ -33,6 +33,10 @@ private final float tieBreakerMultiplier; private int doc = -1; + /* Used when scoring currently matching doc. */ + private float scoreSum; + private float scoreMax; + /** * Creates a new instance of DisjunctionMaxScorer * @@ -90,21 +94,21 @@ @Override public float score() throws IOException { int doc = subScorers[0].docID(); - float[] sum = { subScorers[0].score() }, max = { sum[0] }; + scoreSum = scoreMax = subScorers[0].score(); int size = numScorers; - scoreAll(1, size, doc, sum, max); - scoreAll(2, size, doc, sum, max); - return max[0] + (sum[0] - max[0]) * tieBreakerMultiplier; + scoreAll(1, size, doc); + scoreAll(2, size, doc); + return scoreMax + (scoreSum - scoreMax) * tieBreakerMultiplier; } // Recursively iterate all subScorers that generated last doc computing sum and max - private void scoreAll(int root, int size, int doc, float[] sum, float[] max) throws IOException { + private void scoreAll(int root, int size, int doc) throws IOException { if (root < size && subScorers[root].docID() == doc) { float sub = subScorers[root].score(); - sum[0] += sub; - max[0] = Math.max(max[0], sub); - scoreAll((root<<1)+1, size, doc, sum, max); - scoreAll((root<<1)+2, size, doc, sum, max); + scoreSum += sub; + scoreMax = Math.max(scoreMax, sub); + scoreAll((root<<1)+1, size, doc); + scoreAll((root<<1)+2, size, doc); } }