*highlight: Optimization: remove *-is-redirection call

parse.zsh -oo, before changes:

Running time: 2.5141480000
num  calls                time                       self            name
-----------------------------------------------------------------------------------
 1)  350        2506,66     7,16  100,00%   1713,68     4,90   68,36%  -hsmw-highlight-process
 2) 2800         374,42     0,13   14,94%    374,42     0,13   14,94%  -hsmw-highlight-string
 3) 2450         194,12     0,08    7,74%    133,36     0,05    5,32%  -hsmw-highlight-check-path
 4) 3850          94,01     0,02    3,75%     94,01     0,02    3,75%  -hsmw-highlight-expand-path
 5) 1400          66,67     0,05    2,66%     66,67     0,05    2,66%  (anon)
 6) 8400          54,50     0,01    2,17%     54,50     0,01    2,17%  -hsmw-highlight-is-redirection
 7) 1400          40,93     0,03    1,63%     40,93     0,03    1,63%  -hsmw-highlight-main-type
 8)  700          10,95     0,02    0,44%     10,95     0,02    0,44%  -hsmw-highlight-check-assign

parse.zsh -oo, after changes:

Running time: 2.3994030000
num  calls                time                       self            name
-----------------------------------------------------------------------------------
 1)  350        2391,73     6,83  100,00%   1650,94     4,72   69,03%  -hsmw-highlight-process
 2) 2800         371,19     0,13   15,52%    371,19     0,13   15,52%  -hsmw-highlight-string
 3) 2450         195,75     0,08    8,18%    135,31     0,06    5,66%  -hsmw-highlight-check-path
 4) 3850          93,17     0,02    3,90%     93,17     0,02    3,90%  -hsmw-highlight-expand-path
 5) 1400          67,69     0,05    2,83%     67,69     0,05    2,83%  (anon)
 6) 1400          43,96     0,03    1,84%     43,96     0,03    1,84%  -hsmw-highlight-main-type
 7)  700          11,25     0,02    0,47%     11,25     0,02    0,47%  -hsmw-highlight-check-assign
 8)  350           9,78     0,03    0,41%      9,78     0,03    0,41%  -hsmw-highlight-stack-pop
This commit is contained in:
Sebastian Gniazdowski 2016-10-16 15:08:57 +02:00
parent 0292e6928d
commit 572872a97c

View file

@ -112,16 +112,6 @@ typeset -gA HSMW_HIGHLIGHT_STYLES
fi
}
# Check whether the first argument is a redirection operator token.
# Report result via the exit code.
-hsmw-highlight-is-redirection() {
# A redirection operator token:
# - starts with an optional single-digit number;
# - then, has a '<' or '>' character;
# - is not a process substitution [<(...) or >(...)].
[[ $1 == (<0-9>|)(\<|\>)* ]] && [[ $1 != (\<|\>)$'\x28'* ]]
}
# Resolve alias.
#
# Takes a single argument.
@ -343,7 +333,7 @@ typeset -gA HSMW_HIGHLIGHT_STYLES
fi
# Analyse the current word.
if -hsmw-highlight-is-redirection $arg ; then
if [[ $arg == (<0-9>|)(\<|\>)* ]] && [[ $arg != (\<|\>)$'\x28'* ]]; then
# A '<' or '>', possibly followed by a digit
in_redirection=2
fi