Skip to content

Commit

Permalink
[Refactor] Improve sed usage for performance
Browse files Browse the repository at this point in the history
  • Loading branch information
PeterDaveHello authored and ljharb committed Mar 21, 2017
1 parent dcd008f commit 6ed73b0
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions nvm.sh
Expand Up @@ -890,7 +890,7 @@ nvm_ls() {
fi
if [ -n "${NVM_DIRS_TO_SEARCH1}${NVM_DIRS_TO_SEARCH2}${NVM_DIRS_TO_SEARCH3}" ]; then
VERSIONS="$(command find "${NVM_DIRS_TO_SEARCH1}"/* "${NVM_DIRS_TO_SEARCH2}"/* "${NVM_DIRS_TO_SEARCH3}"/* -name . -o -type d -prune -o -path "${PATTERN}*" \
| command sed "
| command sed -e "
s#${NVM_VERSION_DIR_IOJS}/#versions/${NVM_IOJS_PREFIX}/#;
s#^${NVM_DIR}/##;
\#^[^v]# d;
Expand All @@ -899,7 +899,7 @@ nvm_ls() {
s#^v#${NVM_NODE_PREFIX}/v#;
\#${SEARCH_PATTERN}# !d;
" \
| command sed "s#^\([^/]\{1,\}\)/\(.*\)\$#\2.\1#;" \
-e "s#^\([^/]\{1,\}\)/\(.*\)\$#\2.\1#;" \
| command sort -t. -u -k 1.2,1n -k 2,2n -k 3,3n \
| command sed "
s#\(.*\)\.\([^\.]\{1,\}\)\$#\2-\1#;
Expand Down

0 comments on commit 6ed73b0

Please sign in to comment.