From 6681e6a536f83397e5fe192e6e824b7d41ca9294 Mon Sep 17 00:00:00 2001 From: Dennis Camera Date: Thu, 8 Feb 2024 11:32:16 +0100 Subject: [PATCH] Short-circuit in _p_update as soon as a disabled branch is found --- ygpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/ygpp b/ygpp index 436dd60..57934d1 100755 --- a/ygpp +++ b/ygpp @@ -182,9 +182,14 @@ function eval_shell_cmd(cmd, _k) { } function _p_update(p_name, _i, _s) { + # NOTE: values > 0 are considered true _s = 1 - for (_i = 1; _i <= p_stacks[p_name, "p_last"]; ++_i) - _s = _s && p_stacks[p_name, _i] + for (_i = 1; _i <= p_stacks[p_name, "p_last"]; ++_i) { + if (0 >= p_stacks[p_name, _i]) { + _s = 0 + break + } + } p_stacks[p_name, "p_state"] = _s }