Skip to content

Commit f308643

Browse files
committed
improve BufferedUnionScorer::advance
1 parent b96435b commit f308643

1 file changed

Lines changed: 10 additions & 11 deletions

File tree

src/query/union/buffered_union.rs

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -144,19 +144,18 @@ where
144144
TScorer: Scorer,
145145
TScoreCombiner: ScoreCombiner,
146146
{
147-
#[inline]
148147
fn advance(&mut self) -> DocId {
149-
if self.advance_buffered() {
150-
return self.doc;
151-
}
152-
if !self.refill() {
153-
self.doc = TERMINATED;
154-
return TERMINATED;
155-
}
156-
if !self.advance_buffered() {
157-
return TERMINATED;
148+
// A loop rather than two sequential advance_buffered calls
149+
// produces a single inlined copy
150+
loop {
151+
if self.advance_buffered() {
152+
return self.doc;
153+
}
154+
if !self.refill() {
155+
self.doc = TERMINATED;
156+
return TERMINATED;
157+
}
158158
}
159-
self.doc
160159
}
161160

162161
fn fill_buffer(&mut self, buffer: &mut [DocId; COLLECT_BLOCK_BUFFER_LEN]) -> usize {

0 commit comments

Comments
 (0)