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

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 04:34:55 +03:00 committed by GitHub
parent 95d7df1858
commit fb8031162c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

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