Fix #164: Use fc builtin instead of $history array for lookup

According to a few tests, the `fc` builtin appears to be quite a bit
faster than searching through the `$history` associative array when
dealing with large history files (500K+).
This commit is contained in:
Eric Freese 2016-06-10 13:24:45 -06:00
parent b4b3a82ee3
commit 63816c5da8
2 changed files with 2 additions and 16 deletions

View file

@ -7,12 +7,5 @@
#
_zsh_autosuggest_strategy_default() {
local prefix="$1"
# Get the keys of the history items that match
local -a histkeys
histkeys=(${(k)history[(r)$prefix*]})
# Echo the value of the first key
echo -E "${history[$histkeys[1]]}"
fc -lnrm "$1*" 1 2>/dev/null | head -n 1
}

View file

@ -371,14 +371,7 @@ _zsh_autosuggest_escape_command() {
#
_zsh_autosuggest_strategy_default() {
local prefix="$1"
# Get the keys of the history items that match
local -a histkeys
histkeys=(${(k)history[(r)$prefix*]})
# Echo the value of the first key
echo -E "${history[$histkeys[1]]}"
fc -lnrm "$1*" 1 2>/dev/null | head -n 1
}
#--------------------------------------------------------------------#