From: Felix Eckhofer Date: Mon, 15 Jun 2015 23:46:28 +0000 (+0200) Subject: Speed up `which` by avoiding a loop X-Git-Url: https://git.madduck.net/code/vcsh.git/commitdiff_plain/f208e3d44c625878a2fafbf7037ab6350432b83c?hp=--cc Speed up `which` by avoiding a loop --- f208e3d44c625878a2fafbf7037ab6350432b83c diff --git a/vcsh b/vcsh index 8bfafab..11370f8 100755 --- a/vcsh +++ b/vcsh @@ -427,9 +427,7 @@ use() { which() { [ -e "$VCSH_COMMAND_PARAMETER" ] || fatal "'$VCSH_COMMAND_PARAMETER' does not exist" 1 for VCSH_REPO_NAME in $(list); do - for VCSH_FILE in $(get_files); do - echo "$VCSH_FILE" | grep -q "$VCSH_COMMAND_PARAMETER" && echo "$VCSH_REPO_NAME: $VCSH_FILE" - done + get_files | grep -- "$VCSH_COMMAND_PARAMETER" | sed "s/^/$VCSH_REPO_NAME: /" done | sort -u }