From 73198179f1d0cca0dca93aa4ee6e8a56cf6da1c7 Mon Sep 17 00:00:00 2001 From: Louis Dureuil Date: Mon, 29 May 2023 10:08:27 +0200 Subject: [PATCH] Consistently use wrapping add to avoid overflow in debug when query starts with a separator --- milli/src/search/new/query_term/parse_query.rs | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/milli/src/search/new/query_term/parse_query.rs b/milli/src/search/new/query_term/parse_query.rs index bf90748e4..0120772be 100644 --- a/milli/src/search/new/query_term/parse_query.rs +++ b/milli/src/search/new/query_term/parse_query.rs @@ -77,13 +77,9 @@ pub fn located_query_terms_from_tokens( } } TokenKind::Separator(separator_kind) => { - match separator_kind { - SeparatorKind::Hard => { - position += 1; - } - SeparatorKind::Soft => { - position += 0; - } + // add penalty for hard separators + if let SeparatorKind::Hard = separator_kind { + position = position.wrapping_add(1); } phrase = 'phrase: {