From 74f78a852957f5a7e7a672a5b94a1e7f599197eb Mon Sep 17 00:00:00 2001 From: Pratham Date: Fri, 21 Oct 2022 09:47:38 +0200 Subject: [PATCH] kiss: fix quadratic behaviour (#91) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Not really necessary considering it occurs only when files are actually invalid Example with manually broken linux package: ``` λ time ./kiss i linux > /dev/null -> linux Checking if manifest valid ERROR linux manifest contains 16997 non-existent files Command exited with non-zero status 1 real 0m 0.57s user 0m 0.15s sys 0m 0.42s ``` ``` λ time kiss i linux > /dev/null -> linux Checking if manifest valid ERROR linux manifest contains 16997 non-existent files Command exited with non-zero status 1 real 1m 10.04s user 1m 7.94s sys 0m 2.08s ``` Co-authored-by: git-bruh Reviewed-on: https://codeberg.org/kiss-community/kiss/pulls/91 --- kiss | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/kiss b/kiss index 3c668f9..a1bb3c4 100755 --- a/kiss +++ b/kiss @@ -898,16 +898,17 @@ pkg_manifest_validate() { # NOTE: _pkg comes from caller. log "$_pkg" "Checking if manifest valid" + cnt=0 + while read -r line; do [ -e "$tar_dir/$_pkg$line" ] || [ -h "$tar_dir/$_pkg$line" ] || { printf '%s\n' "$line" - set -- "$@" "$line" + : $((cnt += 1)) } done < "$pkg_db/$_pkg/manifest" - for f do - die "$_pkg" "manifest contains $# non-existent files" - done + equ "$cnt" 0 || + die "$_pkg" "manifest contains $cnt non-existent files" } pkg_manifest_replace() {