From 5d02c6df7f9cd3a2820149886e8a32e7d8e7a566 Mon Sep 17 00:00:00 2001 From: Felix Yan Date: Mon, 10 Oct 2022 12:53:52 +0000 Subject: common: improve performance of find_cached_package find_cached_package was unnecessarily looping over all packages which uses a lot of CPU and could be exceptionally slow when PKGDEST contains a lot of packages. Fix this by adding the target pkgname, pkgver and arch to the glob and only process potential candidates. --- lib/common.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/common.sh b/lib/common.sh index 56e49e6..4ebee4e 100644 --- a/lib/common.sh +++ b/lib/common.sh @@ -146,7 +146,7 @@ find_cached_package() { [[ -d $dir ]] || continue shopt -s extglob nullglob - mapfile -t packages < <(printf "%s\n" "$dir"/*.pkg.tar?(.!(sig|*.*))) + mapfile -t packages < <(printf "%s\n" "$dir"/${targetname}-${targetver}-*${targetarch}.pkg.tar?(.!(sig|*.*))) shopt -u extglob nullglob for pkg in "${packages[@]}"; do -- cgit v1.2.3-54-g00ecf