mirror of
https://github.com/zsh-users/zsh-autosuggestions.git
synced 2025-04-17 11:35:31 +08:00
speed up widget rebinding by removing redundant array subscripts
This commit is contained in:
parent
70f36c007d
commit
73cdb1e4bb
@ -143,21 +143,10 @@ _zsh_autosuggest_feature_detect_zpty_returns_fd() {
|
|||||||
#--------------------------------------------------------------------#
|
#--------------------------------------------------------------------#
|
||||||
|
|
||||||
_zsh_autosuggest_incr_bind_count() {
|
_zsh_autosuggest_incr_bind_count() {
|
||||||
if ((${+_ZSH_AUTOSUGGEST_BIND_COUNTS[$1]})); then
|
local C=${${_ZSH_AUTOSUGGEST_BIND_COUNTS[$1]}:-0}
|
||||||
((_ZSH_AUTOSUGGEST_BIND_COUNTS[$1]++))
|
((++C))
|
||||||
else
|
_ZSH_AUTOSUGGEST_BIND_COUNTS[$1]=$C
|
||||||
_ZSH_AUTOSUGGEST_BIND_COUNTS[$1]=1
|
typeset -gi bind_count=$C
|
||||||
fi
|
|
||||||
|
|
||||||
typeset -gi bind_count=$_ZSH_AUTOSUGGEST_BIND_COUNTS[$1]
|
|
||||||
}
|
|
||||||
|
|
||||||
_zsh_autosuggest_get_bind_count() {
|
|
||||||
if ((${+_ZSH_AUTOSUGGEST_BIND_COUNTS[$1]})); then
|
|
||||||
typeset -gi bind_count=$_ZSH_AUTOSUGGEST_BIND_COUNTS[$1]
|
|
||||||
else
|
|
||||||
typeset -gi bind_count=0
|
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Bind a single widget to an autosuggest widget, saving a reference to the original widget
|
# Bind a single widget to an autosuggest widget, saving a reference to the original widget
|
||||||
@ -173,7 +162,9 @@ _zsh_autosuggest_bind_widget() {
|
|||||||
# Save a reference to the original widget
|
# Save a reference to the original widget
|
||||||
case $widgets[$widget] in
|
case $widgets[$widget] in
|
||||||
# Already bound
|
# Already bound
|
||||||
user:_zsh_autosuggest_(bound|orig)_*);;
|
user:_zsh_autosuggest_(bound|orig)_*)
|
||||||
|
bind_count=${${_ZSH_AUTOSUGGEST_BIND_COUNTS[$1]}:-0}
|
||||||
|
;;
|
||||||
|
|
||||||
# User-defined widget
|
# User-defined widget
|
||||||
user:*)
|
user:*)
|
||||||
@ -195,8 +186,6 @@ _zsh_autosuggest_bind_widget() {
|
|||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
_zsh_autosuggest_get_bind_count $widget
|
|
||||||
|
|
||||||
# Pass the original widget's name explicitly into the autosuggest
|
# Pass the original widget's name explicitly into the autosuggest
|
||||||
# function. Use this passed in widget name to call the original
|
# function. Use this passed in widget name to call the original
|
||||||
# widget instead of relying on the $WIDGET variable being set
|
# widget instead of relying on the $WIDGET variable being set
|
||||||
|
Loading…
Reference in New Issue
Block a user