From 950a740bd46c5e06ff2b4f6d2fefb24fe44b3cd1 Mon Sep 17 00:00:00 2001 From: ad hoc Date: Thu, 31 Mar 2022 18:37:43 +0200 Subject: [PATCH] refactor typos for readability --- milli/src/search/query_tree.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/milli/src/search/query_tree.rs b/milli/src/search/query_tree.rs index c1803f40b..b1c846324 100644 --- a/milli/src/search/query_tree.rs +++ b/milli/src/search/query_tree.rs @@ -276,9 +276,9 @@ pub struct TypoConfig { fn typos(word: String, authorize_typos: bool, config: TypoConfig) -> QueryKind { if authorize_typos { let count = word.chars().count().min(u8::MAX as usize) as u8; - if (0..config.word_len_one_typo).contains(&count) { + if count < config.word_len_one_typo { QueryKind::exact(word) - } else if (config.word_len_one_typo..config.word_len_two_typo).contains(&count) { + } else if count < config.word_len_two_typo { QueryKind::tolerant(1.min(config.max_typos), word) } else { QueryKind::tolerant(2.min(config.max_typos), word)