From 9fea04a6d5761370f7fb719ed472a400ee8be946 Mon Sep 17 00:00:00 2001 From: Chris Ross Date: Tue, 22 Oct 2024 18:33:53 +0100 Subject: [PATCH] Slightly change score strategy for columns Previously, if a column had no match, it would short circuit returning None. This means that if you have a match term on a second column, but the first didn't match, you wouldn't get any match for the row. This change means that non-matching columns are scored as zero, and then if the match has zero score after all columns, then we return zero. --- src/pattern.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/pattern.rs b/src/pattern.rs index 816b0a3..e615622 100644 --- a/src/pattern.rs +++ b/src/pattern.rs @@ -89,9 +89,13 @@ impl MultiPattern { // TODO: wheight columns? let mut score = 0; for ((pattern, _), haystack) in self.cols.iter().zip(haystack) { - score += pattern.score(haystack.slice(..), matcher)? + score += pattern.score(haystack.slice(..), matcher).unwrap_or(0); + } + if score > 0 { + Some(score) + } else { + None } - Some(score) } pub fn is_empty(&self) -> bool {