Repository: meilisearch/meilisearch
File: milli/src/search/new/ranking_rule_graph/proximity/compute_docids.rs (Rust)

Code before:
                left_word.interned(),
                right_prefix.interned(),
                left_phrase,
                forward_proximity,
                backward_proximity,
                &mut docids,
                universe,
            )?;
        }
    }

    for (left_phrase, left_word) in last_words_of_term_derivations(ctx, &left_term.term_subset)? {
        // Before computing the edges, check that the left word and left phrase
        // aren't disjoint with the universe, but only do it if there is more than
        // one word derivation to the right.
        //
        // This is an optimisation to avoid checking for an excessive number of
        // pairs.
        let right_derivs = first_word_of_term_iter(ctx, &right_term.term_subset)?;
        if right_derivs.len() > 1 {
            let universe = &universe;
            if let Some(left_phrase) = left_phrase {
                if universe.is_disjoint(ctx.get_phrase_docids(None, left_phrase)?) {
                    continue;
                }
            } else if let Some(left_word_docids) = ctx.word_docids(Some(universe), left_word)? {
                if universe.is_disjoint(&left_word_docids) {
                    continue;
                }
            }
        }

        for (right_word, right_phrase) in right_derivs {
            compute_non_prefix_edges(
                ctx,
                left_word.interned(),
                right_word,
                left_phrase,
                right_phrase,
                forward_proximity,
                backward_proximity,
                &mut docids,
                universe,
            )?;
        }
    }

    Ok(ComputedCondition {
        docids,
        universe_len: universe.len(),
        start_term_subset: Some(left_term.clone()),

Review comment (suggestion):
It is unclear that we want to pass Some(universe) here, especially since we check `is_disjoint` right afterwards

Code after:
                left_word.interned(),
                right_prefix.interned(),
                left_phrase,
                forward_proximity,
                backward_proximity,
                &mut docids,
                universe,
            )?;
        }
    }

    for (left_phrase, left_word) in last_words_of_term_derivations(ctx, &left_term.term_subset)? {
        // Before computing the edges, check that the left word and left phrase
        // aren't disjoint with the universe, but only do it if there is more than
        // one word derivation to the right.
        //
        // This is an optimisation to avoid checking for an excessive number of
        // pairs.
        let right_derivs = first_word_of_term_iter(ctx, &right_term.term_subset)?;
        if right_derivs.len() > 1 {
            let universe = &universe;
            if let Some(left_phrase) = left_phrase {
                if universe.is_disjoint(ctx.get_phrase_docids(left_phrase)?) {
                    continue;
                }
            } else if let Some(left_word_docids) = ctx.word_docids(Some(universe), left_word)? {
                if left_word_docids.is_empty() {
                    continue;
                }
            }
        }

        for (right_word, right_phrase) in right_derivs {
            compute_non_prefix_edges(
                ctx,
                left_word.interned(),
                right_word,
                left_phrase,
                right_phrase,
                forward_proximity,
                backward_proximity,
                &mut docids,
                universe,
            )?;
        }
    }

    Ok(ComputedCondition {
        docids,
        universe_len: universe.len(),
        start_term_subset: Some(left_term.clone()),