mirror of
https://github.com/zdharma-continuum/history-search-multi-word
synced 2024-11-22 03:13:09 +00:00
*highlight: Optimization: remove *-expand-path calls
Results are too random to store, main execution time varies much, but for sure there is no slowdown.
This commit is contained in:
parent
3b543a4ecc
commit
af73d936de
1 changed files with 5 additions and 16 deletions
|
@ -162,7 +162,7 @@ typeset -gA HSMW_HIGHLIGHT_STYLES
|
||||||
integer multi_func_def=0
|
integer multi_func_def=0
|
||||||
fi
|
fi
|
||||||
emulate -L zsh
|
emulate -L zsh
|
||||||
setopt localoptions extendedglob bareglobqual
|
setopt localoptions extendedglob bareglobqual nonomatch
|
||||||
|
|
||||||
## Variable declarations and initializations
|
## Variable declarations and initializations
|
||||||
local start_pos=0 end_pos highlight_glob=true arg style
|
local start_pos=0 end_pos highlight_glob=true arg style
|
||||||
|
@ -382,7 +382,8 @@ typeset -gA HSMW_HIGHLIGHT_STYLES
|
||||||
(( next_word = next_word | BIT_sudo_opt ))
|
(( next_word = next_word | BIT_sudo_opt ))
|
||||||
(( next_word = next_word | BIT_start ))
|
(( next_word = next_word | BIT_start ))
|
||||||
else
|
else
|
||||||
-hsmw-highlight-expand-path $arg
|
unset REPLY
|
||||||
|
: ${REPLY:=${(Q)~arg}}
|
||||||
-hsmw-highlight-main-type $REPLY
|
-hsmw-highlight-main-type $REPLY
|
||||||
() {
|
() {
|
||||||
# Special-case: command word is '$foo', like that, without braces or anything.
|
# Special-case: command word is '$foo', like that, without braces or anything.
|
||||||
|
@ -646,7 +647,8 @@ typeset -gA HSMW_HIGHLIGHT_STYLES
|
||||||
# Else, return non-zero (and the contents of $REPLY is undefined).
|
# Else, return non-zero (and the contents of $REPLY is undefined).
|
||||||
-hsmw-highlight-check-path()
|
-hsmw-highlight-check-path()
|
||||||
{
|
{
|
||||||
-hsmw-highlight-expand-path $arg;
|
unset REPLY
|
||||||
|
: ${REPLY:=${(Q)~arg}}
|
||||||
local expanded_path="$REPLY"
|
local expanded_path="$REPLY"
|
||||||
|
|
||||||
REPLY=path
|
REPLY=path
|
||||||
|
@ -737,19 +739,6 @@ typeset -gA HSMW_HIGHLIGHT_STYLES
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
# Called with a single positional argument.
|
|
||||||
# Perform filename expansion (tilde expansion) on the argument and set $REPLY to the expanded value.
|
|
||||||
# Does not perform filename generation (globbing).
|
|
||||||
-hsmw-highlight-expand-path()
|
|
||||||
{
|
|
||||||
(( $# == 1 )) || print -r -- >&2 "hsmw-highlight: BUG: -hsmw-highlight-expand-path: called without argument"
|
|
||||||
|
|
||||||
# The $~1 syntax normally performs filename generation, but not when it's on the right-hand side of ${x:=y}.
|
|
||||||
setopt localoptions nonomatch
|
|
||||||
unset REPLY
|
|
||||||
: ${REPLY:=${(Q)~1}}
|
|
||||||
}
|
|
||||||
|
|
||||||
# -------------------------------------------------------------------------------------------------
|
# -------------------------------------------------------------------------------------------------
|
||||||
# Main highlighter initialization
|
# Main highlighter initialization
|
||||||
# -------------------------------------------------------------------------------------------------
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
|
Loading…
Reference in a new issue