*highlight: Optimization: *-stack-pop doesn't need eval

parse.zsh -oo, after changes:

Running time: 1.5681030000
num  calls                time                       self            name
-----------------------------------------------------------------------------------
 1)  350        1560,69     4,46   99,99%   1199,03     3,43   76,82%  -hsmw-highlight-process
 2) 2800         294,91     0,11   18,90%    294,91     0,11   18,90%  -hsmw-highlight-string
 3) 1750          40,71     0,02    2,61%     40,71     0,02    2,61%  -hsmw-highlight-check-path
 4) 1400          20,87     0,01    1,34%     20,87     0,01    1,34%  -hsmw-highlight-main-type
 5)  350           5,17     0,01    0,33%      5,17     0,01    0,33%  -hsmw-highlight-stack-pop
 6)    1           0,07     0,07    0,00%      0,07     0,07    0,00%  -hsmw-highlight-fill-option-variables
 7)    1           0,01     0,01    0,00%      0,01     0,01    0,00%  -hsmw-highlight-init
This commit is contained in:
Sebastian Gniazdowski 2016-11-02 11:24:37 +01:00
parent b4f69992ce
commit 430ebac5a1

View file

@ -160,7 +160,7 @@ __HSMW_HIGHLIGHT_TOKENS_TYPES=(
-hsmw-highlight-stack-pop() {
if [[ $braces_stack[1] == $1 ]]; then
braces_stack=${braces_stack:1}
eval "$2"
style=reserved-word
else
style=unknown-token
fi
@ -421,7 +421,7 @@ __HSMW_HIGHLIGHT_TOKENS_TYPES=(
braces_stack='Y'"$braces_stack"
elif [[ $arg == $'\x7d' ]]; then
# We're at command word, so no need to check $right_brace_is_recognised_everywhere
-hsmw-highlight-stack-pop 'Y' style=reserved-word
-hsmw-highlight-stack-pop 'Y'
[[ $style == "reserved-word" ]] && (( next_word = next_word | 16 ))
fi
;;
@ -514,7 +514,7 @@ __HSMW_HIGHLIGHT_TOKENS_TYPES=(
in_array_assignment=0
(( next_word = next_word | 1 ))
else
-hsmw-highlight-stack-pop 'R' style=reserved-word
-hsmw-highlight-stack-pop 'R'
fi;;
$'\x28\x29') # possibly a function definition
# || false # TODO: or if the previous word was a command word
@ -528,7 +528,7 @@ __HSMW_HIGHLIGHT_TOKENS_TYPES=(
# Additionally, `tt(})' is recognized in any position if neither the
# tt(IGNORE_BRACES) option nor the tt(IGNORE_CLOSE_BRACES) option is set."""
if (( right_brace_is_recognised_everywhere )); then
-hsmw-highlight-stack-pop 'Y' style=reserved-word
-hsmw-highlight-stack-pop 'Y'
[[ $style == reserved-word ]] && (( next_word = next_word | 16 ))
#else
# Fall through to the catchall case at the end.