From dd8004ccbf58b546f48205d2878d9101bbfcaadc Mon Sep 17 00:00:00 2001 From: davidovski Date: Mon, 6 Jun 2022 18:39:20 +0100 Subject: fixed sort to be faster --- src/get.sh | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'src/get.sh') diff --git a/src/get.sh b/src/get.sh index 4296569..4a15bd7 100755 --- a/src/get.sh +++ b/src/get.sh @@ -8,7 +8,7 @@ list_deps() { [ -f $tree_file ] && for dep in $(cat "$tree_file"); do echo $dep - done | sort -u + done } # list all dependencies and sub dependencies of a package @@ -30,18 +30,21 @@ resolve_deps () { local package=$1 #only add if not already added - if ! echo ${deps} | grep -q "\b$package\b"; then + case " $deps " in + *" $package "*);; + *) deps="$deps $package" i=$((i+1)) - fi + ;; + esac for dep in $(list_deps $package); do # if not already checked - if echo $@ | grep -qv "\b$dep\b"; then - set -- $@ $dep - fi + case " $@ $deps " in + *" $dep "*) ;; + *) set -- $@ $dep;; + esac done - shift ${QUIET} || hbar -T "${CHECKMARK} resolving dependencies" $i $((i + $#)) -- cgit v1.2.1