*highlight: Optimization: better code that handles history expansion

parse.zsh -oo, after changes:

Running time: 1.8102530000
num  calls                time                       self            name
-----------------------------------------------------------------------------------
 1)  350        1802,80     5,15  100,00%   1325,15     3,79   73,50%  -hsmw-highlight-process
 2) 2800         339,52     0,12   18,83%    339,52     0,12   18,83%  -hsmw-highlight-string
 3) 2450          81,13     0,03    4,50%     81,13     0,03    4,50%  -hsmw-highlight-check-path
 4) 1400          39,34     0,03    2,18%     39,34     0,03    2,18%  -hsmw-highlight-main-type
 5)  350           9,77     0,03    0,54%      9,77     0,03    0,54%  -hsmw-highlight-stack-pop
 6)  350           7,89     0,02    0,44%      7,89     0,02    0,44%  -hsmw-highlight-path-separators
 7)    1           0,08     0,08    0,00%      0,08     0,08    0,00%  -hsmw-highlight-fill-option-variables
 8)    1           0,01     0,01    0,00%      0,01     0,01    0,00%  -hsmw-highlight-init
This commit is contained in:
Sebastian Gniazdowski 2016-10-25 17:28:10 +02:00
parent b8f92d4f89
commit 2b7656552a

View file

@ -465,7 +465,7 @@ __HSMW_HIGHLIGHT_TOKENS_TYPES=(
# Assignment to a scalar parameter or to array
# (For array assignments, the command doesn't start until the ")" token.)
[[ $arg[-1] == '(' ]] && in_array_assignment=1 || (( next_word = next_word | BIT_start ))
elif [[ $arg[0,1] = $histchars[0,1] ]] && (( $#arg[0,2] == 2 )); then
elif [[ $arg[1] = $histchars[1] && -n "${arg[2]}" ]]; then
style=history-expansion
elif [[ $arg[0,1] == $histchars[2,2] ]]; then
style=history-expansion