diff --git a/milli/src/search/matches/matching_words.rs b/milli/src/search/matches/matching_words.rs index 1f6ead8a9..25d447d0c 100644 --- a/milli/src/search/matches/matching_words.rs +++ b/milli/src/search/matches/matching_words.rs @@ -225,7 +225,7 @@ fn bytes_to_highlight(source: &str, target: &str) -> usize { for (col, char_t) in target.chars().enumerate() { let col = col + 1; let last_match_row = *last_row.get(&char_t).unwrap_or(&0); - let cost = if char_s == char_t { 0 } else { 1 }; + let cost = usize::from(char_s != char_t); let dist_add = matrix[(row, col + 1)] + 1; let dist_del = matrix[(row + 1, col)] + 1; diff --git a/milli/src/update/facet/incremental.rs b/milli/src/update/facet/incremental.rs index c6735224d..fd253b146 100644 --- a/milli/src/update/facet/incremental.rs +++ b/milli/src/update/facet/incremental.rs @@ -329,7 +329,7 @@ impl FacetsUpdateIncrementalInner { let key = FacetGroupKey { field_id, level, left_bound: insertion_key.left_bound.clone() }; - let value = FacetGroupValue { size: size_left as u8, bitmap: values_left }; + let value = FacetGroupValue { size: size_left, bitmap: values_left }; (key, value) }; @@ -345,7 +345,7 @@ impl FacetsUpdateIncrementalInner { } let key = FacetGroupKey { field_id, level, left_bound: right_left_bound.to_vec() }; - let value = FacetGroupValue { size: size_right as u8, bitmap: values_right }; + let value = FacetGroupValue { size: size_right, bitmap: values_right }; (key, value) }; drop(iter); @@ -373,8 +373,7 @@ impl FacetsUpdateIncrementalInner { let highest_level = get_highest_level(txn, self.db, field_id)?; - let result = - self.insert_in_level(txn, field_id, highest_level as u8, facet_value, docids)?; + let result = self.insert_in_level(txn, field_id, highest_level, facet_value, docids)?; match result { InsertionResult::InPlace => return Ok(()), InsertionResult::Expand => return Ok(()), @@ -425,7 +424,7 @@ impl FacetsUpdateIncrementalInner { level: highest_level + 1, left_bound: first_key.unwrap().left_bound, }; - let value = FacetGroupValue { size: group_size as u8, bitmap: values }; + let value = FacetGroupValue { size: group_size, bitmap: values }; to_add.push((key.into_owned(), value)); } // now we add the rest of the level, in case its size is > group_size * min_level_size @@ -584,8 +583,7 @@ impl FacetsUpdateIncrementalInner { } let highest_level = get_highest_level(txn, self.db, field_id)?; - let result = - self.delete_in_level(txn, field_id, highest_level as u8, facet_value, docids)?; + let result = self.delete_in_level(txn, field_id, highest_level, facet_value, docids)?; match result { DeletionResult::InPlace => return Ok(()), DeletionResult::Reduce { .. } => return Ok(()), diff --git a/milli/src/update/words_prefixes_fst.rs b/milli/src/update/words_prefixes_fst.rs index 193956c7a..57fed0922 100644 --- a/milli/src/update/words_prefixes_fst.rs +++ b/milli/src/update/words_prefixes_fst.rs @@ -36,7 +36,7 @@ impl<'t, 'u, 'i> WordsPrefixesFst<'t, 'u, 'i> { /// Default value is `4` bytes. This value must be between 1 and 25 will be clamped /// to these bounds, otherwise. pub fn max_prefix_length(&mut self, value: usize) -> &mut Self { - self.max_prefix_length = value.min(25).max(1); // clamp [1, 25] + self.max_prefix_length = value.clamp(1, 25); self }