perf(bash-v2): speed up filtering entries with descriptions

Use simple prefix match instead of single word `compgen -W` command
substitution for each candidate match.
This commit is contained in:
Ville Skyttä 2022-05-04 00:39:07 +03:00
parent f17e5a27c9
commit ce36da4fef

View file

@ -183,8 +183,7 @@ __%[1]s_handle_standard_completion_case() {
# Strip any description before checking the length # Strip any description before checking the length
comp=${compline%%%%$tab*} comp=${compline%%%%$tab*}
# Only consider the completions that match # Only consider the completions that match
comp=$(compgen -W "$comp" -- "$cur") [[ $comp == "$cur"* ]] || continue
[[ -z $comp ]] && continue
COMPREPLY+=("$compline") COMPREPLY+=("$compline")
if ((${#comp}>longest)); then if ((${#comp}>longest)); then
longest=${#comp} longest=${#comp}