*highlight: Optimization: reuse "local", etc. keywords

./parse -oo, after changes:

Running time: 1.8522630000
num  calls                time                       self            name
-----------------------------------------------------------------------------------
 1)  350        1844,79     5,27  100,00%   1368,04     3,91   74,15%  -hsmw-highlight-process
 2) 2800         338,28     0,12   18,34%    338,28     0,12   18,34%  -hsmw-highlight-string
 3) 2450          81,31     0,03    4,41%     81,31     0,03    4,41%  -hsmw-highlight-check-path
 4) 1400          39,39     0,03    2,14%     39,39     0,03    2,14%  -hsmw-highlight-main-type
 5)  350           9,81     0,03    0,53%      9,81     0,03    0,53%  -hsmw-highlight-stack-pop
 6)  350           7,95     0,02    0,43%      7,95     0,02    0,43%  -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 16:37:38 +02:00
parent 46c907d524
commit d34d812c71

View file

@ -229,21 +229,19 @@ __HSMW_HIGHLIGHT_TOKENS_TYPES=(
emulate -L zsh emulate -L zsh
setopt localoptions extendedglob bareglobqual nonomatch noksharrays setopt localoptions extendedglob bareglobqual nonomatch noksharrays
## Variable declarations and initializations # Variable declarations and initializations
local start_pos=0 end_pos highlight_glob=1 arg style # in_array_assignment true between 'a=(' and the matching ')'
local in_array_assignment=0 # true between 'a=(' and the matching ')' # braces_stack: "R" for round, "Q" for square, "Y" for curly
integer arg_type=0 # Can be 0, 1, 2 or 3 - look up ^ local start_pos=0 end_pos highlight_glob=1 arg style in_array_assignment=0 MATCH expanded_path braces_stack
local -a options_to_set # used in callees # arg_type can be 0, 1, 2 or 3, i.e. precommand, control flow, command separator
integer arg_type=0 MBEGIN MEND in_redirection
local -a options_to_set match mbegin mend
local buf="$1" local buf="$1"
integer len="${#buf}" integer len="${#buf}"
local braces_stack # "R" for round, "Q" for square, "Y" for curly
(( path_dirs_was_set )) && options_to_set+=( PATH_DIRS ) (( path_dirs_was_set )) && options_to_set+=( PATH_DIRS )
local -a match mbegin mend
local MATCH; integer MBEGIN MEND
# State machine # State machine
# #
# The states are: # The states are:
@ -284,8 +282,6 @@ __HSMW_HIGHLIGHT_TOKENS_TYPES=(
integer BIT_start=1 BIT_regular=2 BIT_sudo_opt=4 BIT_sudo_arg=8 BIT_always=16 integer BIT_start=1 BIT_regular=2 BIT_sudo_opt=4 BIT_sudo_arg=8 BIT_always=16
integer this_word=BIT_start next_word=0 integer this_word=BIT_start next_word=0
integer in_redirection
local expanded_path
# Processing buffer # Processing buffer
local proc_buf="$buf" local proc_buf="$buf"
for arg in ${interactive_comments-${(z)buf}} \ for arg in ${interactive_comments-${(z)buf}} \