*highlight: Optimization: don't do ! (( ... )), instead do (( ... ==0 ))

parse.zsh -oo, after changes:

Running time: 1.7914460000
num  calls                time                       self            name
-----------------------------------------------------------------------------------
 1)  350        1784,00     5,10  100,00%   1310,16     3,74   73,44%  -hsmw-highlight-process
 2) 2800         334,93     0,12   18,77%    334,93     0,12   18,77%  -hsmw-highlight-string
 3) 2450          81,08     0,03    4,54%     81,08     0,03    4,54%  -hsmw-highlight-check-path
 4) 1400          40,07     0,03    2,25%     40,07     0,03    2,25%  -hsmw-highlight-main-type
 5)  350           9,76     0,03    0,55%      9,76     0,03    0,55%  -hsmw-highlight-stack-pop
 6)  350           8,00     0,02    0,45%      8,00     0,02    0,45%  -hsmw-highlight-path-separators
 7)    1           0,07     0,07    0,00%      0,07     0,07    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:58:49 +02:00
parent a558600315
commit 1a5ac41130

View file

@ -153,7 +153,7 @@ __HSMW_HIGHLIGHT_TOKENS_TYPES=(
REPLY=none REPLY=none
fi fi
fi fi
if ! (( $+REPLY )); then if (( $+REPLY == 0 )); then
REPLY="${$(LC_ALL=C builtin type -w -- $1 2>/dev/null)#*: }" REPLY="${$(LC_ALL=C builtin type -w -- $1 2>/dev/null)#*: }"
fi fi
if (( $+__hsmw_highlight_main__command_type_cache )); then if (( $+__hsmw_highlight_main__command_type_cache )); then
@ -584,7 +584,7 @@ __HSMW_HIGHLIGHT_TOKENS_TYPES=(
;; ;;
esac esac
fi fi
if ! (( already_added )); then if (( already_added == 0 )); then
# ADD # ADD
[[ "${HSMW_HIGHLIGHT_STYLES[$style]}" != "none" ]] && reply+=("$start_pos $end_pos ${HSMW_HIGHLIGHT_STYLES[$style]}") [[ "${HSMW_HIGHLIGHT_STYLES[$style]}" != "none" ]] && reply+=("$start_pos $end_pos ${HSMW_HIGHLIGHT_STYLES[$style]}")
[[ $style == path || $style == path_prefix ]] && -hsmw-highlight-path-separators [[ $style == path || $style == path_prefix ]] && -hsmw-highlight-path-separators