From 7ec7200378b1b5f91b04c176c163eaef723f6b0e Mon Sep 17 00:00:00 2001 From: Louis Dureuil Date: Wed, 8 Jan 2025 16:25:44 +0100 Subject: [PATCH] Check valid_facet_value as part of a filter of the iterator --- crates/milli/src/update/facet/new_incremental.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/crates/milli/src/update/facet/new_incremental.rs b/crates/milli/src/update/facet/new_incremental.rs index 82e1c31fb..e917e41b6 100644 --- a/crates/milli/src/update/facet/new_incremental.rs +++ b/crates/milli/src/update/facet/new_incremental.rs @@ -91,8 +91,12 @@ impl FacetsUpdateIncrementalInner { FacetGroupKey { field_id: self.field_id, level: parent_level, left_bound: &[] }; let mut last_parent: Option> = None; - let mut child_it = - changed_children.drain(..).filter(|child| valid_facet_value(&child.facet_value)); + let mut child_it = changed_children + // drain all changed children + .drain(..) + // keep only children whose value is valid in the LMDB sense + .filter(|child| valid_facet_value(&child.facet_value)); + // `while let` rather than `for` because we advance `child_it` inside of the loop 'current_level: while let Some(child) = child_it.next() { if let Some(last_parent) = &last_parent { if &child.facet_value >= last_parent {