From d633ac5b9d6c7229d50b1eaacbe57ae9cc5d9ae6 Mon Sep 17 00:00:00 2001 From: ad hoc Date: Tue, 15 Mar 2022 16:37:22 +0100 Subject: [PATCH] optimize word prefix pair --- .../word_prefix_pair_proximity_docids.rs | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/milli/src/update/word_prefix_pair_proximity_docids.rs b/milli/src/update/word_prefix_pair_proximity_docids.rs index 284bb8981..be0ddf005 100644 --- a/milli/src/update/word_prefix_pair_proximity_docids.rs +++ b/milli/src/update/word_prefix_pair_proximity_docids.rs @@ -155,20 +155,20 @@ impl<'t, 'u, 'i> WordPrefixPairProximityDocids<'t, 'u, 'i> { // All of the word prefix pairs in the database that have a w2 // that is contained in the `suppr_pw` set must be removed as well. - let mut iter = self - .index - .word_prefix_pair_proximity_docids - .remap_data_type::() - .iter_mut(self.wtxn)?; - while let Some(((_, w2, _), _)) = iter.next().transpose()? { - if del_prefix_fst_words.contains(w2.as_bytes()) { - // Delete this entry as the w2 prefix is no more in the words prefix fst. - unsafe { iter.del_current()? }; + if !del_prefix_fst_words.is_empty() { + let mut iter = self + .index + .word_prefix_pair_proximity_docids + .remap_data_type::() + .iter_mut(self.wtxn)?; + while let Some(((_, w2, _), _)) = iter.next().transpose()? { + if del_prefix_fst_words.contains(w2.as_bytes()) { + // Delete this entry as the w2 prefix is no more in the words prefix fst. + unsafe { iter.del_current()? }; + } } } - drop(iter); - // We finally write and merge the new word prefix pair proximity docids // in the LMDB database. sorter_into_lmdb_database(