Skip to content

Commit e033bf8

Browse files
committed
Remove redundant autocomplete word sort and dedup.
1 parent fd6c7de commit e033bf8

File tree

1 file changed

+5
-10
lines changed

1 file changed

+5
-10
lines changed

src/autocomplete.rs

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,12 @@ impl Autocomplete {
2525

2626
/// Build trie for a language from words. Words are normalized and sorted before insertion.
2727
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-
3628
let mut b = TrieBuilder::new();
37-
for word in words {
38-
b.push(word);
29+
for w in words {
30+
let wn = normalize_word(&w);
31+
if !wn.is_empty() {
32+
b.push(wn);
33+
}
3934
}
4035
self.tries.insert(lang.to_string(), b.build());
4136
}

0 commit comments

Comments
 (0)