We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent fd6c7de commit e033bf8Copy full SHA for e033bf8
src/autocomplete.rs
@@ -25,17 +25,12 @@ impl Autocomplete {
25
26
/// Build trie for a language from words. Words are normalized and sorted before insertion.
27
pub fn build(&mut self, lang: &str, words: Vec<String>) {
28
- let mut words: Vec<String> = words
29
- .into_iter()
30
- .map(|w| normalize_word(&w))
31
- .filter(|w| !w.is_empty())
32
- .collect();
33
- words.sort();
34
- words.dedup();
35
-
36
let mut b = TrieBuilder::new();
37
- for word in words {
38
- b.push(word);
+ for w in words {
+ let wn = normalize_word(&w);
+ if !wn.is_empty() {
+ b.push(wn);
+ }
39
}
40
self.tries.insert(lang.to_string(), b.build());
41
0 commit comments