*highlight: Optimization: remove "return" keyword from *-main-type

parse.zsh -oo, before changes:

Running time: 1.5856540000
num  calls                time                       self            name
-----------------------------------------------------------------------------------
 1)  350        1577,71     4,51   99,99%   1205,79     3,45   76,42%  -hsmw-highlight-process
 2) 2800         295,44     0,11   18,72%    295,44     0,11   18,72%  -hsmw-highlight-string
 3) 1750          40,91     0,02    2,59%     40,91     0,02    2,59%  -hsmw-highlight-check-path
 4) 1400          25,58     0,02    1,62%     25,58     0,02    1,62%  -hsmw-highlight-main-type
 5)  350           9,98     0,03    0,63%      9,98     0,03    0,63%  -hsmw-highlight-stack-pop
 6)    1           0,13     0,13    0,01%      0,13     0,13    0,01%  -hsmw-highlight-fill-option-variables
 7)    1           0,01     0,01    0,00%      0,01     0,01    0,00%  -hsmw-highlight-init

parse.zsh -oo, after changes:

Running time: 1.5778930000
num  calls                time                       self            name
-----------------------------------------------------------------------------------
 1)  350        1570,41     4,49   99,99%   1205,58     3,44   76,76%  -hsmw-highlight-process
 2) 2800         293,42     0,10   18,68%    293,42     0,10   18,68%  -hsmw-highlight-string
 3) 1750          41,16     0,02    2,62%     41,16     0,02    2,62%  -hsmw-highlight-check-path
 4) 1400          20,32     0,01    1,29%     20,32     0,01    1,29%  -hsmw-highlight-main-type
 5)  350           9,93     0,03    0,63%      9,93     0,03    0,63%  -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 09:31:15 +01:00
parent c918483dcc
commit 1c56551a67

View file

@ -119,7 +119,7 @@ __HSMW_HIGHLIGHT_TOKENS_TYPES=(
# The result will be stored in REPLY.
-hsmw-highlight-main-type() {
REPLY=$__hsmw_highlight_main__command_type_cache[(e)$1]
[[ -n "$REPLY" ]] && return
[[ -z "$REPLY" ]] && {
if zmodload -e zsh/parameter; then
if (( $+commands[(e)$1] )); then
@ -148,6 +148,8 @@ __HSMW_HIGHLIGHT_TOKENS_TYPES=(
[[ -z "$REPLY" ]] && REPLY="${$(LC_ALL=C builtin type -w -- $1 2>/dev/null)##*: }"
__hsmw_highlight_main__command_type_cache[(e)$1]=$REPLY
}
}
# Resolve alias.