Repository: meilisearch/meilisearch
File: milli/src/search/facet/filter.rs (Rust)

Code before:
            }
            FilterCondition::Or(subfilters) => subfilters
                .iter()
                .cloned()
                .map(|f| Self::inner_evaluate(&f.into(), rtxn, index, filterable_fields, universe))
                .union(),
            FilterCondition::And(subfilters) => {
                let mut subfilters_iter = subfilters.iter();
                if let Some(first_subfilter) = subfilters_iter.next() {
                    let mut bitmap = Self::inner_evaluate(
                        &(first_subfilter.clone()).into(),
                        rtxn,
                        index,
                        filterable_fields,
                        universe,
                    )?;
                    for f in subfilters_iter {
                        if bitmap.is_empty() {
                            return Ok(bitmap);
                        }
                        // TODO We are doing the intersections two times,
                        //      it could be more efficient
                        //      Can't I just replace this `&=` by an `=`?
                        bitmap &= Self::inner_evaluate(
                            &(f.clone()).into(),
                            rtxn,
                            index,
                            filterable_fields,
                            Some(&bitmap),
                        )?;
                    }
                    Ok(bitmap)
                } else {
                    Ok(RoaringBitmap::new())
                }
            }
            FilterCondition::GeoLowerThan { point, radius } => {
                if filterable_fields.contains("_geo") {
                    let base_point: [f64; 2] =
                        [point[0].parse_finite_float()?, point[1].parse_finite_float()?];
                    if !(-90.0..=90.0).contains(&base_point[0]) {
                        return Err(point[0].as_external_error(BadGeoError::Lat(base_point[0])))?;
                    }
                    if !(-180.0..=180.0).contains(&base_point[1]) {
                        return Err(point[1].as_external_error(BadGeoError::Lng(base_point[1])))?;
                    }
                    let radius = radius.parse_finite_float()?;
                    let rtree = match index.geo_rtree(rtxn)? {
                        Some(rtree) => rtree,
                        None => return Ok(RoaringBitmap::new()),
                    };

Review comment (suggestion):
Pretty sure this is simply an `=` here. All the intersections were already made. I prefer to keep this extra `&=` in case we forgot an intersection when deserializing somewhere.

Code after:
                    }))?
                }
            }
            FilterCondition::Or(subfilters) => subfilters
                .iter()
                .cloned()
                .map(|f| Self::inner_evaluate(&f.into(), rtxn, index, filterable_fields, universe))
                .union(),
            FilterCondition::And(subfilters) => {
                let mut subfilters_iter = subfilters.iter();
                if let Some(first_subfilter) = subfilters_iter.next() {
                    let mut bitmap = Self::inner_evaluate(
                        &(first_subfilter.clone()).into(),
                        rtxn,
                        index,
                        filterable_fields,
                        universe,
                    )?;
                    for f in subfilters_iter {
                        if bitmap.is_empty() {
                            return Ok(bitmap);
                        }
                        // TODO We are doing the intersections two times,
                        //      it could be more efficient
                        //      Can't I just replace this `&=` by an `=`?
                        bitmap &= Self::inner_evaluate(
                            &(f.clone()).into(),
                            rtxn,
                            index,
                            filterable_fields,
                            Some(&bitmap),
                        )?;
                    }
                    Ok(bitmap)
                } else {
                    Ok(RoaringBitmap::new())
                }
            }
            FilterCondition::GeoLowerThan { point, radius } => {
                if filterable_fields.contains("_geo") {
                    let base_point: [f64; 2] =
                        [point[0].parse_finite_float()?, point[1].parse_finite_float()?];
                    if !(-90.0..=90.0).contains(&base_point[0]) {
                        return Err(point[0].as_external_error(BadGeoError::Lat(base_point[0])))?;
                    }
                    if !(-180.0..=180.0).contains(&base_point[1]) {
                        return Err(point[1].as_external_error(BadGeoError::Lng(base_point[1])))?;
                    }
                    let radius = radius.parse_finite_float()?;
                    let rtree = match index.geo_rtree(rtxn)? {
                        Some(rtree) => rtree,