[Perf] Improve performance of listing aliases

Fixes #3054
William Baker 2023-03-10 00:53:29 -05:00 committed by Jordan Harband
parent ea3b65f02e
commit ffcb5213e2
No known key found for this signature in database
GPG Key ID: 9F6A681E35EF8B56
1 changed files with 4 additions and 8 deletions

12
nvm.sh
View File

@ -1068,7 +1068,7 @@ nvm_list_aliases() {
(
local ALIAS_NAME
for ALIAS_NAME in "$(nvm_node_prefix)" "stable" "unstable"; do
for ALIAS_NAME in "$(nvm_node_prefix)" "stable" "unstable" "$(nvm_iojs_prefix)"; do
{
# shellcheck disable=SC2030,SC2031 # (https://github.com/koalaman/shellcheck/issues/2217)
if [ ! -f "${NVM_ALIAS_DIR}/${ALIAS_NAME}" ] && { [ -z "${ALIAS}" ] || [ "${ALIAS_NAME}" = "${ALIAS}" ]; }; then
@ -1077,11 +1077,6 @@ nvm_list_aliases() {
} &
done
wait
ALIAS_NAME="$(nvm_iojs_prefix)"
# shellcheck disable=SC2030,SC2031 # (https://github.com/koalaman/shellcheck/issues/2217)
if [ ! -f "${NVM_ALIAS_DIR}/${ALIAS_NAME}" ] && { [ -z "${ALIAS}" ] || [ "${ALIAS_NAME}" = "${ALIAS}" ]; }; then
NVM_NO_COLORS="${NVM_NO_COLORS-}" NVM_CURRENT="${NVM_CURRENT}" nvm_print_default_alias "${ALIAS_NAME}"
fi
) | sort
(
@ -1376,9 +1371,10 @@ nvm_ls() {
if [ "${NVM_ADD_SYSTEM-}" = true ]; then
if [ -z "${PATTERN}" ] || [ "${PATTERN}" = 'v' ]; then
VERSIONS="${VERSIONS}$(command printf '\n%s' 'system')"
VERSIONS="${VERSIONS}
system"
elif [ "${PATTERN}" = 'system' ]; then
VERSIONS="$(command printf '%s' 'system')"
VERSIONS="system"
fi
fi