Restrict FST search to the first letter of the word

This commit is contained in:
Clément Renault 2019-12-20 16:36:37 +01:00
parent 534143e91d
commit 1163f390b3
No known key found for this signature in database
GPG Key ID: 0151CDAB43460DAE

View File

@ -467,7 +467,13 @@ fn fetch_matches<'txn, 'tag>(
dfa_time += before_dfa.elapsed();
let mut number_of_words = 0;
let mut stream = words.search(&dfa).into_stream();
let byte = query.as_bytes()[0];
let mut stream = if byte == u8::max_value() {
words.search(&dfa).ge(&[byte]).into_stream()
} else {
words.search(&dfa).ge(&[byte]).lt(&[byte + 1]).into_stream()
};
// while let Some(input) = stream.next() {
loop {