*highlight: Optimization: remove *-path-separators call (inline code)

parse.zsh -oo, after changes:

Running time: 1.6395310000
num  calls                time                       self            name
-----------------------------------------------------------------------------------
 1)  350        1632,01     4,66  100,00%   1203,20     3,44   73,72%  -hsmw-highlight-process
 2) 2800         322,99     0,12   19,79%    322,99     0,12   19,79%  -hsmw-highlight-string
 3) 2450          71,63     0,03    4,39%     71,63     0,03    4,39%  -hsmw-highlight-check-path
 4) 1400          24,49     0,02    1,50%     24,49     0,02    1,50%  -hsmw-highlight-main-type
 5)  350           9,70     0,03    0,59%      9,70     0,03    0,59%  -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-10-26 09:57:21 +02:00
parent 8cd7464b85
commit 5367ca4e1b

View file

@ -559,7 +559,13 @@ __HSMW_HIGHLIGHT_TOKENS_TYPES=(
if (( already_added == 0 )); then
# ADD
[[ "${HSMW_HIGHLIGHT_STYLES[$style]}" != "none" ]] && reply+=("$start_pos $end_pos ${HSMW_HIGHLIGHT_STYLES[$style]}")
[[ $style == "path" ]] && -hsmw-highlight-path-separators
[[ $style == "path" && -n "$HSMW_HIGHLIGHT_STYLES[path_pathseparator]" && "$HSMW_HIGHLIGHT_STYLES[path]" != "$HSMW_HIGHLIGHT_STYLES[path_pathseparator]" ]] && {
local pos
for (( pos = start_pos; pos <= end_pos; pos++ )) ; do
# ADD
[[ ${buf[pos]} == "/" ]] && reply+=("$(( pos - 1 )) $pos ${HSMW_HIGHLIGHT_STYLES[$style_pathsep]}")
done
}
fi
if (( arg_type == 3 )); then
if [[ $arg == ';' ]] && (( in_array_assignment )); then
@ -589,16 +595,6 @@ __HSMW_HIGHLIGHT_TOKENS_TYPES=(
done
}
-hsmw-highlight-path-separators()
{
[[ -z "$HSMW_HIGHLIGHT_STYLES[path_pathseparator]" || "$HSMW_HIGHLIGHT_STYLES[path]" == "$HSMW_HIGHLIGHT_STYLES[path_pathseparator]" ]] && return 0
local pos
for (( pos = start_pos; pos <= end_pos; pos++ )) ; do
# ADD
[[ ${buf[pos]} == "/" ]] && reply+=("$(( pos - 1 )) $pos ${HSMW_HIGHLIGHT_STYLES[$style_pathsep]}")
done
}
# Check if $arg is a path.
# If yes, return 0 and in $REPLY the style to use.
# Else, return non-zero (and the contents of $REPLY is undefined).