From e8afca614cacc2b4df7a8a07464f4df5ed1f7185 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Renault?= Date: Mon, 1 Jul 2019 14:34:06 +0200 Subject: [PATCH] chore: Little clean ups of meilidb-core --- meilidb-core/src/distinct_map.rs | 1 - meilidb-core/src/lib.rs | 2 +- meilidb-core/src/query_builder.rs | 2 +- meilidb-core/src/reordered_attrs.rs | 4 ++++ 4 files changed, 6 insertions(+), 3 deletions(-) diff --git a/meilidb-core/src/distinct_map.rs b/meilidb-core/src/distinct_map.rs index 3ac956245..c53ad0ea4 100644 --- a/meilidb-core/src/distinct_map.rs +++ b/meilidb-core/src/distinct_map.rs @@ -1,5 +1,4 @@ use std::hash::Hash; - use hashbrown::HashMap; pub struct DistinctMap { diff --git a/meilidb-core/src/lib.rs b/meilidb-core/src/lib.rs index f764d544e..6db5e45ad 100644 --- a/meilidb-core/src/lib.rs +++ b/meilidb-core/src/lib.rs @@ -162,7 +162,7 @@ impl fmt::Debug for RawDocument { } fn raw_documents_from_matches(matches: SetBuf<(DocumentId, TmpMatch, Highlight)>) -> Vec { - let mut docs_ranges = Vec::<(DocumentId, Range, Vec)>::new(); + let mut docs_ranges: Vec<(_, Range, _)> = Vec::new(); let mut matches2 = Matches::with_capacity(matches.len()); for group in matches.linear_group_by(|(a, _, _), (b, _, _)| a == b) { diff --git a/meilidb-core/src/query_builder.rs b/meilidb-core/src/query_builder.rs index a59fcfa4a..90c9a898b 100644 --- a/meilidb-core/src/query_builder.rs +++ b/meilidb-core/src/query_builder.rs @@ -229,7 +229,7 @@ impl<'c, S, FI> QueryBuilder<'c, S, FI> } pub fn add_searchable_attribute(&mut self, attribute: u16) { - let reorders = self.searchable_attrs.get_or_insert_with(Default::default); + let reorders = self.searchable_attrs.get_or_insert_with(ReorderedAttrs::new); reorders.insert_attribute(attribute); } } diff --git a/meilidb-core/src/reordered_attrs.rs b/meilidb-core/src/reordered_attrs.rs index 5b1567d1d..ad7b2c324 100644 --- a/meilidb-core/src/reordered_attrs.rs +++ b/meilidb-core/src/reordered_attrs.rs @@ -5,6 +5,10 @@ pub struct ReorderedAttrs { } impl ReorderedAttrs { + pub fn new() -> ReorderedAttrs { + ReorderedAttrs { count: 0, reorders: Vec::new() } + } + pub fn insert_attribute(&mut self, attribute: u16) { self.reorders.resize(attribute as usize + 1, None); self.reorders[attribute as usize] = Some(self.count as u16);