From b1905dfa2409a8c7aa5a08431b51ad6c81cc73bd Mon Sep 17 00:00:00 2001 From: ManyTheFish Date: Thu, 7 Apr 2022 17:05:44 +0200 Subject: [PATCH] Make split_best_frequency returns references instead of owned data --- milli/src/search/query_tree.rs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/milli/src/search/query_tree.rs b/milli/src/search/query_tree.rs index a45034a3b..f8dd82a57 100644 --- a/milli/src/search/query_tree.rs +++ b/milli/src/search/query_tree.rs @@ -257,7 +257,10 @@ impl<'a> QueryTreeBuilder<'a> { } /// Split the word depending on the frequency of subwords in the database documents. -fn split_best_frequency(ctx: &impl Context, word: &str) -> heed::Result> { +fn split_best_frequency<'a>( + ctx: &impl Context, + word: &'a str, +) -> heed::Result> { let chars = word.char_indices().skip(1); let mut best = None; @@ -273,7 +276,7 @@ fn split_best_frequency(ctx: &impl Context, word: &str) -> heed::Result { let mut children = synonyms(ctx, &[&word])?.unwrap_or_default(); if let Some((left, right)) = split_best_frequency(ctx, &word)? { - children.push(Operation::Phrase(vec![left, right])); + children.push(Operation::Phrase(vec![left.to_string(), right.to_string()])); } let (word_len_one_typo, word_len_two_typo) = ctx.min_word_len_for_typo()?; let exact_words = ctx.exact_words()?; @@ -499,8 +502,8 @@ fn create_matching_words( } if let Some((left, right)) = split_best_frequency(ctx, &word)? { - let left = MatchingWord::new(left, 0, false); - let right = MatchingWord::new(right, 0, false); + let left = MatchingWord::new(left.to_string(), 0, false); + let right = MatchingWord::new(right.to_string(), 0, false); matching_words.push((vec![left, right], vec![id])); }