mirror of
https://github.com/zdharma-continuum/history-search-multi-word
synced 2024-11-25 04:40:21 +00:00
*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:
parent
46c907d524
commit
d34d812c71
1 changed files with 8 additions and 12 deletions
|
@ -229,21 +229,19 @@ __HSMW_HIGHLIGHT_TOKENS_TYPES=(
|
|||
emulate -L zsh
|
||||
setopt localoptions extendedglob bareglobqual nonomatch noksharrays
|
||||
|
||||
## Variable declarations and initializations
|
||||
local start_pos=0 end_pos highlight_glob=1 arg style
|
||||
local in_array_assignment=0 # true between 'a=(' and the matching ')'
|
||||
integer arg_type=0 # Can be 0, 1, 2 or 3 - look up ^
|
||||
local -a options_to_set # used in callees
|
||||
# Variable declarations and initializations
|
||||
# in_array_assignment true between 'a=(' and the matching ')'
|
||||
# braces_stack: "R" for round, "Q" for square, "Y" for curly
|
||||
local start_pos=0 end_pos highlight_glob=1 arg style in_array_assignment=0 MATCH expanded_path braces_stack
|
||||
# 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"
|
||||
integer len="${#buf}"
|
||||
|
||||
local braces_stack # "R" for round, "Q" for square, "Y" for curly
|
||||
|
||||
(( path_dirs_was_set )) && options_to_set+=( PATH_DIRS )
|
||||
|
||||
local -a match mbegin mend
|
||||
local MATCH; integer MBEGIN MEND
|
||||
|
||||
# State machine
|
||||
#
|
||||
# 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 this_word=BIT_start next_word=0
|
||||
|
||||
integer in_redirection
|
||||
local expanded_path
|
||||
# Processing buffer
|
||||
local proc_buf="$buf"
|
||||
for arg in ${interactive_comments-${(z)buf}} \
|
||||
|
|
Loading…
Reference in a new issue