From 2b7656552a2fa9ea7cceee23f2e63ef4265220fe Mon Sep 17 00:00:00 2001 From: Sebastian Gniazdowski Date: Tue, 25 Oct 2016 17:28:10 +0200 Subject: [PATCH] *highlight: Optimization: better code that handles history expansion parse.zsh -oo, after changes: Running time: 1.8102530000 num calls time self name ----------------------------------------------------------------------------------- 1) 350 1802,80 5,15 100,00% 1325,15 3,79 73,50% -hsmw-highlight-process 2) 2800 339,52 0,12 18,83% 339,52 0,12 18,83% -hsmw-highlight-string 3) 2450 81,13 0,03 4,50% 81,13 0,03 4,50% -hsmw-highlight-check-path 4) 1400 39,34 0,03 2,18% 39,34 0,03 2,18% -hsmw-highlight-main-type 5) 350 9,77 0,03 0,54% 9,77 0,03 0,54% -hsmw-highlight-stack-pop 6) 350 7,89 0,02 0,44% 7,89 0,02 0,44% -hsmw-highlight-path-separators 7) 1 0,08 0,08 0,00% 0,08 0,08 0,00% -hsmw-highlight-fill-option-variables 8) 1 0,01 0,01 0,00% 0,01 0,01 0,00% -hsmw-highlight-init --- hsmw-highlight | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hsmw-highlight b/hsmw-highlight index c76627c..10cc413 100644 --- a/hsmw-highlight +++ b/hsmw-highlight @@ -465,7 +465,7 @@ __HSMW_HIGHLIGHT_TOKENS_TYPES=( # Assignment to a scalar parameter or to array # (For array assignments, the command doesn't start until the ")" token.) [[ $arg[-1] == '(' ]] && in_array_assignment=1 || (( next_word = next_word | BIT_start )) - elif [[ $arg[0,1] = $histchars[0,1] ]] && (( $#arg[0,2] == 2 )); then + elif [[ $arg[1] = $histchars[1] && -n "${arg[2]}" ]]; then style=history-expansion elif [[ $arg[0,1] == $histchars[2,2] ]]; then style=history-expansion