Skip to content
Myr

Cache values in local variables to avoid repeated lookups.

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Jordan Harband · committed by Jordan Harband · parent f0d81e2 · Browse files · 1 file+23 added−13 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+23 added−13 removed

  • other:+23 added−13 removed

1 file+23 added−13 removed

modified:nvm.sh+23 added-13 removed
471 unmodified lines
472 if nvm_resolve_alias "$PATTERN"; then473 return474 fi475476 local NVM_IOJS_PREFIX477 NVM_IOJS_PREFIX="$(nvm_iojs_prefix)"478 local NVM_NODE_PREFIX479 NVM_NODE_PREFIX="$(nvm_node_prefix)"480 local NVM_VERSION_DIR_IOJS481 NVM_VERSION_DIR_IOJS="$(nvm_version_dir iojs)"482 local NVM_VERSION_DIR_NEW483 NVM_VERSION_DIR_NEW="$(nvm_version_dir new)"484 local NVM_VERSION_DIR_OLD485 NVM_VERSION_DIR_OLD="$(nvm_version_dir old)"486487 case "$PATTERN" in477 "$(nvm_iojs_prefix)" | "$(nvm_node_prefix)")488 "$NVM_IOJS_PREFIX" | "$NVM_NODE_PREFIX" )489 PATTERN="$PATTERN-"490 ;;491 *)492 PATTERN=$(nvm_ensure_version_prefix $PATTERN)
7 unmodified lines
500 VERSIONS="$(nvm_add_iojs_prefix "$PATTERN")"501 fi502 else503 case "$PATTERN" in493 "$(nvm_iojs_prefix)-" | "$(nvm_node_prefix)-" | "system")494 ;;504 "$NVM_IOJS_PREFIX-" | "$NVM_NODE_PREFIX-" | "system") ;;505 *)506 local NUM_VERSION_GROUPS507 NUM_VERSION_GROUPS="$(nvm_num_version_groups "$PATTERN")"508 if [ "_$NUM_VERSION_GROUPS" = "_2" ] || [ "_$NUM_VERSION_GROUPS" = "_1" ]; then
13 unmodified lines
522 local NVM_DIRS_TO_SEARCH523 local NVM_ADD_SYSTEM524 NVM_ADD_SYSTEM=false525 if nvm_is_iojs_version "$PATTERN"; then516 NVM_DIRS_TO_TEST_AND_SEARCH="$(nvm_version_dir iojs)"526 NVM_DIRS_TO_TEST_AND_SEARCH="$NVM_VERSION_DIR_IOJS"527 PATTERN="$(nvm_strip_iojs_prefix "$PATTERN")"528 if nvm_has_system_iojs; then529 NVM_ADD_SYSTEM=true530 fi521 elif [ "_$PATTERN" = "_$(nvm_node_prefix)-" ]; then522 NVM_DIRS_TO_TEST_AND_SEARCH="$(nvm_version_dir old) $(nvm_version_dir new)"531 elif [ "_$PATTERN" = "_$NVM_NODE_PREFIX-" ]; then532 NVM_DIRS_TO_TEST_AND_SEARCH="$NVM_VERSION_DIR_OLD $NVM_VERSION_DIR_NEW"533 PATTERN=''534 if nvm_has_system_node; then535 NVM_ADD_SYSTEM=true536 fi537 else528 NVM_DIRS_TO_TEST_AND_SEARCH="$(nvm_version_dir old) $(nvm_version_dir new) $(nvm_version_dir iojs)"538 NVM_DIRS_TO_TEST_AND_SEARCH="$NVM_VERSION_DIR_OLD $NVM_VERSION_DIR_NEW $NVM_VERSION_DIR_IOJS"539 if nvm_has_system_iojs || nvm_has_system_node; then540 NVM_ADD_SYSTEM=true541 fi542 fi
6 unmodified lines
549 if [ -z "$PATTERN" ]; then550 PATTERN='v'551 fi552 VERSIONS="$(command find $NVM_DIRS_TO_SEARCH -maxdepth 1 -type d -name "$PATTERN*" \543 | command sed "s#$(nvm_version_dir iojs)/#"$(nvm_iojs_prefix)"-#" \544 | command grep -v "$(nvm_version_dir iojs)" \553 | command sed "s#$NVM_VERSION_DIR_IOJS/#"$NVM_IOJS_PREFIX"-#" \554 | command grep -v "$NVM_VERSION_DIR_IOJS" \555 | command sed "s#^$NVM_DIR/##" \556 | command grep -v -e '^versions$' \557 | command sed 's#^versions/##' \548 | sed -e 's/^v/node-v/' \549 | sed -e 's#^\(iojs\)[-/]v#\1.v#' | sed -e 's#^\(node\)[-/]v#\1.v#' \558 | sed -e "s/^v/$NVM_NODE_PREFIX-v/" \559 | sed -e "s#^\($NVM_IOJS_PREFIX\)[-/]v#\1.v#" | sed -e "s#^\($NVM_NODE_PREFIX\)[-/]v#\1.v#" \560 | command sort -t. -u -k 2.2,2n -k 3,3n -k 4,4n \561 | command sort -s -t- -k1.1,1.1 \552 | command sed 's/^\(iojs\)\./\1-/' \553 | command sed 's/^node\.//')"562 | command sed "s/^\($NVM_IOJS_PREFIX\)\./\1-/" \563 | command sed "s/^$NVM_NODE_PREFIX\.//")"564565 if [ $ZHS_HAS_SHWORDSPLIT_UNSET -eq 1 ] && nvm_has "unsetopt"; then566 unsetopt shwordsplit567 fi
1016 unmodified lines