mirror of
https://github.com/zdharma-continuum/history-search-multi-word
synced 2024-11-24 20:33:04 +00:00
*highlight: Optimization – save options outside main highlighting fun
Lower 18xx are being seen, like below: Running time: 1.8632000000 num calls time self name ----------------------------------------------------------------------------------- 1) 350 1855,72 5,30 100,00% 1376,89 3,93 74,19% -hsmw-highlight-process 2) 2800 342,38 0,12 18,45% 342,38 0,12 18,45% -hsmw-highlight-string 3) 2450 80,16 0,03 4,32% 80,16 0,03 4,32% -hsmw-highlight-check-path 4) 1400 38,99 0,03 2,10% 38,99 0,03 2,10% -hsmw-highlight-main-type 5) 350 9,83 0,03 0,53% 9,83 0,03 0,53% -hsmw-highlight-stack-pop 6) 350 7,47 0,02 0,40% 7,47 0,02 0,40% -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
0400ad6d76
commit
2bef2b9343
3 changed files with 50 additions and 21 deletions
|
@ -15,6 +15,11 @@
|
|||
# zstyle ":history-search-multi-word" highlight-color "fg=yellow,bold"
|
||||
# zstyle ":plugin:history-search-multi-word" synhl "yes"
|
||||
|
||||
[[ "$__HSMW_MH_SOURCED" != "1" ]] && source "$HSMW_REPO_DIR/hsmw-highlight"
|
||||
local right_brace_is_recognised_everywhere
|
||||
integer path_dirs_was_set multi_func_def ointeractive_comments
|
||||
-hsmw-highlight-fill-option-variables
|
||||
|
||||
emulate -LR zsh
|
||||
setopt typesetsilent extendedglob noshortloops localtraps
|
||||
|
||||
|
@ -154,8 +159,6 @@ _hsmw_main() {
|
|||
region_highlight+=( "$(( offset + ${#txt_before} )) $(( offset + ${#txt_before} + ${#entry} + 1 )) $__hsmw_active" )
|
||||
}
|
||||
|
||||
[[ "$__HSMW_MH_SOURCED" != "1" ]] && source "$HSMW_REPO_DIR/hsmw-highlight"
|
||||
|
||||
_hsmw_main
|
||||
|
||||
_hsmw_simulate_widget() {
|
||||
|
|
|
@ -188,28 +188,44 @@ __HSMW_HIGHLIGHT_TOKENS_TYPES=(
|
|||
fi
|
||||
}
|
||||
|
||||
# Below are variables that must be defined in outer
|
||||
# scope so that they are reachable in *-process()
|
||||
#
|
||||
# local right_brace_is_recognised_everywhere
|
||||
# integer path_dirs_was_set
|
||||
# integer multi_func_def
|
||||
# integer ointeractive_comments
|
||||
-hsmw-highlight-fill-option-variables() {
|
||||
if [[ -o ignore_braces ]] || eval '[[ -o ignore_close_braces ]] 2>/dev/null'; then
|
||||
right_brace_is_recognised_everywhere=0
|
||||
else
|
||||
right_brace_is_recognised_everywhere=1
|
||||
fi
|
||||
|
||||
if [[ -o path_dirs ]]; then
|
||||
path_dirs_was_set=1
|
||||
else
|
||||
path_dirs_was_set=0
|
||||
fi
|
||||
|
||||
if [[ -o multi_func_def ]]; then
|
||||
multi_func_def=1
|
||||
else
|
||||
multi_func_def=0
|
||||
fi
|
||||
|
||||
if [[ -o interactive_comments ]]; then
|
||||
ointeractive_comments=1
|
||||
else
|
||||
ointeractive_comments=0
|
||||
fi
|
||||
}
|
||||
|
||||
# Main syntax highlighting function.
|
||||
-hsmw-highlight-process()
|
||||
{
|
||||
## Before we even 'emulate -L', we must test a few options that would reset.
|
||||
if [[ -o interactive_comments ]]; then
|
||||
local interactive_comments= # set to empty
|
||||
fi
|
||||
if [[ -o ignore_braces ]] || eval '[[ -o ignore_close_braces ]] 2>/dev/null'; then
|
||||
local right_brace_is_recognised_everywhere=0
|
||||
else
|
||||
local right_brace_is_recognised_everywhere=1
|
||||
fi
|
||||
if [[ -o path_dirs ]]; then
|
||||
integer path_dirs_was_set=1
|
||||
else
|
||||
integer path_dirs_was_set=0
|
||||
fi
|
||||
if [[ -o multi_func_def ]]; then
|
||||
integer multi_func_def=1
|
||||
else
|
||||
integer multi_func_def=0
|
||||
fi
|
||||
(( ointeractive_comments )) && local interactive_comments= # _set_ to empty
|
||||
|
||||
emulate -L zsh
|
||||
setopt localoptions extendedglob bareglobqual nonomatch noksharrays
|
||||
|
||||
|
|
|
@ -61,6 +61,11 @@ if [[ "$1" = "-o" || "$1" = "-oo" ]]; then
|
|||
SECONDS=0
|
||||
|
||||
-hsmw-highlight-init
|
||||
|
||||
local right_brace_is_recognised_everywhere
|
||||
integer path_dirs_was_set multi_func_def ointeractive_comments
|
||||
-hsmw-highlight-fill-option-variables
|
||||
|
||||
local line
|
||||
for line in "${long_input[@]}"; do
|
||||
reply=( )
|
||||
|
@ -79,6 +84,11 @@ elif [[ -r "$1" ]]; then
|
|||
|
||||
reply=( )
|
||||
-hsmw-highlight-init
|
||||
|
||||
local right_brace_is_recognised_everywhere
|
||||
integer path_dirs_was_set multi_func_def ointeractive_comments
|
||||
-hsmw-highlight-fill-option-variables
|
||||
|
||||
-hsmw-highlight-process "$buf"
|
||||
|
||||
print "Running time: $SECONDS"
|
||||
|
|
Loading…
Reference in a new issue