Skip to content

Commit

Permalink
[Perf] Improve performance of listing aliases
Browse files Browse the repository at this point in the history
Fixes #3054
  • Loading branch information
bbrk24 authored and ljharb committed Mar 10, 2023
1 parent ea3b65f commit ffcb521
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions nvm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

(
Expand Down Expand Up @@ -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

Expand Down

0 comments on commit ffcb521

Please sign in to comment.