*highlight: Optimization: cdpath_dir declared outside *-check-path

parse.zsh -oo, after changes:

Running time: 1.5547670000
num  calls                time                       self            name
-----------------------------------------------------------------------------------
 1)  350        1547,01     4,42   99,99%   1183,65     3,38   76,50%  -hsmw-highlight-process
 2) 2800         266,89     0,10   17,25%    266,89     0,10   17,25%  -hsmw-highlight-string
 3) 2450          62,13     0,03    4,02%     62,13     0,03    4,02%  -hsmw-highlight-check-path
 4) 1400          24,75     0,02    1,60%     24,75     0,02    1,60%  -hsmw-highlight-main-type
 5)  350           9,59     0,03    0,62%      9,59     0,03    0,62%  -hsmw-highlight-stack-pop
 6)    1           0,14     0,14    0,01%      0,14     0,14    0,01%  -hsmw-highlight-fill-option-variables
 7)    1           0,02     0,02    0,00%      0,02     0,02    0,00%  -hsmw-highlight-init
This commit is contained in:
Sebastian Gniazdowski 2016-10-26 11:13:12 +02:00
parent 4b70d8d977
commit fc6379f8d5

View file

@ -222,8 +222,8 @@ __HSMW_HIGHLIGHT_TOKENS_TYPES=(
# Variable declarations and initializations
# in_array_assignment true between 'a=(' and the matching ')'
# braces_stack: "R" for round, "Q" for square, "Y" for curly
# mybuf is used in sub-functions
local start_pos=0 end_pos highlight_glob=1 arg style in_array_assignment=0 MATCH expanded_path braces_stack buf=$1 mybuf
# mybuf, cdpath_dir are used in sub-functions
local start_pos=0 end_pos highlight_glob=1 arg style in_array_assignment=0 MATCH expanded_path braces_stack buf=$1 mybuf cdpath_dir
# arg_type can be 0, 1, 2 or 3, i.e. precommand, control flow, command separator
# idx and end_idx are used in sub-functions
integer arg_type=0 MBEGIN MEND in_redirection len=${#buf} already_added offset idx end_idx
@ -623,7 +623,6 @@ __HSMW_HIGHLIGHT_TOKENS_TYPES=(
[[ -e $expanded_path ]] && return 0
# Search the path in CDPATH
local cdpath_dir
for cdpath_dir in $cdpath ; do
[[ -e "$cdpath_dir/$expanded_path" ]] && return 0
done