Can you explain this comment a bit more, I'm not sure I understand:
The first patch worked like conjunctions, the scorer first advanced the approximation and then called nextDoc() on the approximation until it found a document that matches. So when scores were not needed, you could just stop calling "matches()" as soon as one of the clauses that are positionned on the current doc matches. I don't think it's an important optimization but was worth mentioning.
The new patch is different. In the priority queue, we store both a reference to the sub scorer and its approximation. And the disjunction scorer moves to the next doc by moving the *scorer* in the pq, while the approximation moves to the next candidate by moving the *approximation* in the pq.
Why do we pass needsScores to these disjunctions? It seems to only optimize the case where someone doesnt needScores but calls freq() anyway.
I didn't want to optimize anything in particular, but having the freq computed eagerly made the two-phase view a bit easier to implement. I can try to make it lazy again.