small optimization: don't add docBase unless score may be competitive

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1149256 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Michael McCandless 2011-07-21 16:17:00 +00:00
parent 8ea59829e4
commit 7fb6c2ecfe

View File

@ -82,8 +82,13 @@ public abstract class TopScoreDocCollector extends TopDocsCollector<ScoreDoc> {
assert !Float.isNaN(score); assert !Float.isNaN(score);
totalHits++; totalHits++;
if (score < pqTop.score) {
// Doesn't compete w/ bottom entry in queue
return;
}
doc += docBase; doc += docBase;
if (score < pqTop.score || (score == pqTop.score && doc > pqTop.doc)) { if (score == pqTop.score && doc > pqTop.doc) {
// Break tie in score by doc ID:
return; return;
} }
pqTop.doc = doc; pqTop.doc = doc;