speedup
This commit is contained in:
parent
90ac9c9e20
commit
57b500d083
|
@ -76,6 +76,7 @@ typeset -gA _p9k_term=(
|
||||||
';&' ''
|
';&' ''
|
||||||
';|' ''
|
';|' ''
|
||||||
')' ''
|
')' ''
|
||||||
|
'()' ''
|
||||||
)
|
)
|
||||||
|
|
||||||
function _p9k_extract_commands() {
|
function _p9k_extract_commands() {
|
||||||
|
@ -86,9 +87,11 @@ function _p9k_extract_commands() {
|
||||||
|
|
||||||
typeset -ga _p9k_commands=()
|
typeset -ga _p9k_commands=()
|
||||||
|
|
||||||
|
local -r id='$(<->|[[:alpha:]_][[:IDENT:]]#)'
|
||||||
|
local -r var="\$$id|\${$id}|\"\$$id\"|\"\${$id}\""
|
||||||
|
|
||||||
local -i e
|
local -i e
|
||||||
local id='$(<->|[[:alpha:]_][[:IDENT:]]#)'
|
local skip n s r
|
||||||
local skip n s r var="\$$id|\${$id}|\"\$$id\"|\"\${$id}\""
|
|
||||||
local -a aln alp alf v commands match mbegin mend
|
local -a aln alp alf v commands match mbegin mend
|
||||||
|
|
||||||
[[ -o interactive_comments ]] && local tokens=(${(Z+C+)1}) || local tokens=(${(z)1})
|
[[ -o interactive_comments ]] && local tokens=(${(Z+C+)1}) || local tokens=(${(z)1})
|
||||||
|
@ -99,12 +102,12 @@ function _p9k_extract_commands() {
|
||||||
alp[-1]=()
|
alp[-1]=()
|
||||||
if (( $#tokens == alf[-1] )); then
|
if (( $#tokens == alf[-1] )); then
|
||||||
alf[-1]=()
|
alf[-1]=()
|
||||||
e=0
|
(( e = 0 ))
|
||||||
else
|
else
|
||||||
e=$#skip
|
(( e = $#skip ))
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
e=$#skip
|
(( e = $#skip ))
|
||||||
fi
|
fi
|
||||||
|
|
||||||
while (( $#tokens )) || break; do
|
while (( $#tokens )) || break; do
|
||||||
|
@ -134,15 +137,18 @@ function _p9k_extract_commands() {
|
||||||
done
|
done
|
||||||
|
|
||||||
if [[ -n $skip ]]; then
|
if [[ -n $skip ]]; then
|
||||||
if [[ $token == $~skip ]]; then
|
if [[ $skip == '^' ]]; then
|
||||||
skip=
|
|
||||||
if (( $+_p9k_term[$token] )); then
|
if (( $+_p9k_term[$token] )); then
|
||||||
[[ $token == ';'[';&|'] ]] && skip='\)|esac'
|
if [[ $token == '()' ]]; then
|
||||||
_p9k_commands+=($commands)
|
skip=
|
||||||
commands=()
|
else
|
||||||
elif [[ $token == '()' ]]; then
|
_p9k_commands+=($commands)
|
||||||
|
[[ $token == ';'[';&|'] ]] && skip='\)|esac' || skip=
|
||||||
|
fi
|
||||||
commands=()
|
commands=()
|
||||||
fi
|
fi
|
||||||
|
elif [[ $token == $~skip ]]; then
|
||||||
|
skip=
|
||||||
fi
|
fi
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
|
@ -177,9 +183,7 @@ function _p9k_extract_commands() {
|
||||||
fi
|
fi
|
||||||
|
|
||||||
commands+=${:-${(Q)${~token}}}
|
commands+=${:-${(Q)${~token}}}
|
||||||
|
skip='^'
|
||||||
# '|' '||' ';' '&' '&&' '|&' '&!' '&|' ';;' ';&' ';|' ')' '()'
|
|
||||||
skip='\||\|\||;|&|&&|\|&|&!|&\||;;|;&|;\||\)|}|\(\)'
|
|
||||||
done
|
done
|
||||||
|
|
||||||
_p9k_commands+=($commands)
|
_p9k_commands+=($commands)
|
||||||
|
|
Loading…
Reference in New Issue