'main': Optimize the path_prefix check.
Computing ${#array} is O(N), whereas checking 0 is O(1).
This commit is contained in:
parent
62e2d05f91
commit
f56e3fad23
@ -1117,9 +1117,10 @@ _zsh_highlight_main_highlighter_check_path()
|
|||||||
# If this word ends the buffer, check if it's the prefix of a valid path.
|
# If this word ends the buffer, check if it's the prefix of a valid path.
|
||||||
if (( has_end && (len == end_pos) )) &&
|
if (( has_end && (len == end_pos) )) &&
|
||||||
[[ $WIDGET != zle-line-finish ]]; then
|
[[ $WIDGET != zle-line-finish ]]; then
|
||||||
|
# TODO: When we've dropped support for pre-5.0.6 zsh, use the *(Y1) glob qualifier here.
|
||||||
local -a tmp
|
local -a tmp
|
||||||
tmp=( ${expanded_path}*(N) )
|
tmp=( ${expanded_path}*(N) )
|
||||||
(( $#tmp > 0 )) && REPLY=path_prefix && return 0
|
(( ${+tmp[1]} )) && REPLY=path_prefix && return 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# It's not a path.
|
# It's not a path.
|
||||||
|
Loading…
Reference in New Issue
Block a user