From d9d7abe8a93d37b0487ad4351266a49163c78dc9 Mon Sep 17 00:00:00 2001 From: "Joshua A. Anderson" Date: Tue, 20 Aug 2024 08:07:18 -0400 Subject: [PATCH] Implement short-circuit evaluation for `group.include.all`. --- doc/src/release-notes.md | 1 + src/project.rs | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/doc/src/release-notes.md b/doc/src/release-notes.md index 763f23e..5092f6a 100644 --- a/doc/src/release-notes.md +++ b/doc/src/release-notes.md @@ -18,6 +18,7 @@ * `clean` now cleans all caches by default. * Submit jobs with `--constraint="scratch"` by default on Delta. * Submit jobs with `--constraint="nvme"` by default on Frontier. +* `group.include.all` now employs short circuit evaluation. *Fixed:* diff --git a/src/project.rs b/src/project.rs index 50f82f7..a3dcc41 100644 --- a/src/project.rs +++ b/src/project.rs @@ -211,7 +211,7 @@ impl Project { Error::JSONPointerNotFound(name.clone(), include.clone()) })?; - if expr::evaluate_json_comparison(comparison, actual, expected) + if !expr::evaluate_json_comparison(comparison, actual, expected) .ok_or_else(|| { Error::CannotCompareInclude( actual.clone(), @@ -220,8 +220,9 @@ impl Project { ) })? { - matches += 1; + break; } + matches += 1; } Ok(matches == conditions.len()) }