mirror of
https://github.com/zdharma-continuum/history-search-multi-word
synced 2025-02-16 11:08:23 +00:00
*highlight: Optimization: remove *-resolve-alias call
parse.zsh -oo, after changes: Running time: 1.5813580000 num calls time self name ----------------------------------------------------------------------------------- 1) 350 1573,92 4,50 99,99% 1206,50 3,45 76,65% -hsmw-highlight-process 2) 2800 294,35 0,11 18,70% 294,35 0,11 18,70% -hsmw-highlight-string 3) 1750 40,74 0,02 2,59% 40,74 0,02 2,59% -hsmw-highlight-check-path 4) 1400 22,48 0,02 1,43% 22,48 0,02 1,43% -hsmw-highlight-main-type 5) 350 9,86 0,03 0,63% 9,86 0,03 0,63% -hsmw-highlight-stack-pop 6) 1 0,07 0,07 0,00% 0,07 0,07 0,00% -hsmw-highlight-fill-option-variables 7) 1 0,01 0,01 0,00% 0,01 0,01 0,00% -hsmw-highlight-init
This commit is contained in:
parent
ee30daa40b
commit
2955679446
1 changed files with 2 additions and 16 deletions
|
@ -152,19 +152,6 @@ __HSMW_HIGHLIGHT_TOKENS_TYPES=(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# Resolve alias.
|
|
||||||
#
|
|
||||||
# Takes a single argument.
|
|
||||||
#
|
|
||||||
# The result will be stored in REPLY.
|
|
||||||
-hsmw-highlight-resolve-alias() {
|
|
||||||
if zmodload -e zsh/parameter; then
|
|
||||||
REPLY=${aliases[$arg]}
|
|
||||||
else
|
|
||||||
REPLY="${"$(alias -- $arg)"#*=}"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
# Check that the top of $braces_stack has the expected value. If it does, set
|
# Check that the top of $braces_stack has the expected value. If it does, set
|
||||||
# the style according to $2; otherwise, set style=unknown-token.
|
# the style according to $2; otherwise, set style=unknown-token.
|
||||||
#
|
#
|
||||||
|
@ -225,7 +212,7 @@ __HSMW_HIGHLIGHT_TOKENS_TYPES=(
|
||||||
# in_array_assignment true between 'a=(' and the matching ')'
|
# in_array_assignment true between 'a=(' and the matching ')'
|
||||||
# braces_stack: "R" for round, "Q" for square, "Y" for curly
|
# braces_stack: "R" for round, "Q" for square, "Y" for curly
|
||||||
# mybuf, cdpath_dir are used in sub-functions
|
# mybuf, cdpath_dir are used in sub-functions
|
||||||
local start_pos="$2" end_pos highlight_glob=1 arg style in_array_assignment=0 MATCH expanded_path braces_stack buf="$1" mybuf cdpath_dir cur_cmd
|
local start_pos="$2" end_pos highlight_glob=1 arg style in_array_assignment=0 MATCH expanded_path braces_stack buf="$1" mybuf cdpath_dir cur_cmd alias_target
|
||||||
# arg_type can be 0, 1, 2 or 3, i.e. precommand, control flow, command separator
|
# arg_type can be 0, 1, 2 or 3, i.e. precommand, control flow, command separator
|
||||||
# idx and end_idx are used in sub-functions
|
# idx and end_idx are used in sub-functions
|
||||||
# for this_word and next_word look below at commented integers and at state machine description
|
# for this_word and next_word look below at commented integers and at state machine description
|
||||||
|
@ -456,8 +443,7 @@ __HSMW_HIGHLIGHT_TOKENS_TYPES=(
|
||||||
style=unknown-token
|
style=unknown-token
|
||||||
else
|
else
|
||||||
style=alias
|
style=alias
|
||||||
-hsmw-highlight-resolve-alias $arg
|
zmodload -e zsh/parameter && alias_target=${aliases[$arg]} || alias_target="${"$(alias -- $arg)"#*=}"
|
||||||
local alias_target="$REPLY"
|
|
||||||
[[ ${__HSMW_HIGHLIGHT_TOKENS_TYPES[$alias_target]} = "1" && "$arg_type" != "1" ]] && __HSMW_HIGHLIGHT_TOKENS_TYPES[$arg]="1"
|
[[ ${__HSMW_HIGHLIGHT_TOKENS_TYPES[$alias_target]} = "1" && "$arg_type" != "1" ]] && __HSMW_HIGHLIGHT_TOKENS_TYPES[$arg]="1"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue