summaryrefslogtreecommitdiff
path: root/internal/parse.zsh
diff options
context:
space:
mode:
authorromkatv <roman.perepelitsa@gmail.com>2020-01-11 13:13:13 +0300
committerromkatv <roman.perepelitsa@gmail.com>2020-01-11 13:13:13 +0300
commit57b500d083097fa796173b172e3b0cb4fbd3e1e8 (patch)
tree68ecc0ce73028cec4ca2c223f0ee7db9c7fb6565 /internal/parse.zsh
parent90ac9c9e20abb23750da95279ca553ada06019fa (diff)
speedup
Diffstat (limited to 'internal/parse.zsh')
-rw-r--r--internal/parse.zsh32
1 files changed, 18 insertions, 14 deletions
diff --git a/internal/parse.zsh b/internal/parse.zsh
index c0df3c2d..ba18a2dd 100644
--- a/internal/parse.zsh
+++ b/internal/parse.zsh
@@ -76,6 +76,7 @@ typeset -gA _p9k_term=(
';&' ''
';|' ''
')' ''
+ '()' ''
)
function _p9k_extract_commands() {
@@ -86,9 +87,11 @@ function _p9k_extract_commands() {
typeset -ga _p9k_commands=()
+ local -r id='$(<->|[[:alpha:]_][[:IDENT:]]#)'
+ local -r var="\$$id|\${$id}|\"\$$id\"|\"\${$id}\""
+
local -i e
- local id='$(<->|[[:alpha:]_][[:IDENT:]]#)'
- local skip n s r var="\$$id|\${$id}|\"\$$id\"|\"\${$id}\""
+ local skip n s r
local -a aln alp alf v commands match mbegin mend
[[ -o interactive_comments ]] && local tokens=(${(Z+C+)1}) || local tokens=(${(z)1})
@@ -99,12 +102,12 @@ function _p9k_extract_commands() {
alp[-1]=()
if (( $#tokens == alf[-1] )); then
alf[-1]=()
- e=0
+ (( e = 0 ))
else
- e=$#skip
+ (( e = $#skip ))
fi
else
- e=$#skip
+ (( e = $#skip ))
fi
while (( $#tokens )) || break; do
@@ -134,15 +137,18 @@ function _p9k_extract_commands() {
done
if [[ -n $skip ]]; then
- if [[ $token == $~skip ]]; then
- skip=
+ if [[ $skip == '^' ]]; then
if (( $+_p9k_term[$token] )); then
- [[ $token == ';'[';&|'] ]] && skip='\)|esac'
- _p9k_commands+=($commands)
- commands=()
- elif [[ $token == '()' ]]; then
+ if [[ $token == '()' ]]; then
+ skip=
+ else
+ _p9k_commands+=($commands)
+ [[ $token == ';'[';&|'] ]] && skip='\)|esac' || skip=
+ fi
commands=()
fi
+ elif [[ $token == $~skip ]]; then
+ skip=
fi
continue
fi
@@ -177,9 +183,7 @@ function _p9k_extract_commands() {
fi
commands+=${:-${(Q)${~token}}}
-
- # '|' '||' ';' '&' '&&' '|&' '&!' '&|' ';;' ';&' ';|' ')' '()'
- skip='\||\|\||;|&|&&|\|&|&!|&\||;;|;&|;\||\)|}|\(\)'
+ skip='^'
done
_p9k_commands+=($commands)