Skip to content
Myr

perf(bash-v2): short-circuit descriptionless candidate lists (#1686)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

If the list of candidates has no descriptions, short circuit all the description processing logic, basically just do a `compgen -W` for the whole list and be done with it. We could conceivably do some optimizations like this and more when generating the completions with `--no-descriptions` in Go code, by omitting some parts we know won't be needed, or doing some things differently. But doing it this way in bash, the improvements are available also to completions generated with descriptions enabled when they are invoked for completion cases that produce no descriptions. The result after this for descriptionless entries seems fast enough so it seems there's no immediate need to look into doing that.

authored by Ville Skyttä · committed by GitHub · parent f17e5a2 · Browse files · 1 file+8 added−0 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+8 added−0 removed

  • other:+8 added−0 removed

1 file+8 added−0 removed

modified:bash_completionsV2.go+8 added
174 unmodified lines
175176__%[1]s_handle_standard_completion_case() {177 local tab=$'\t' comp178179 # Short circuit to optimize if we don't have descriptions180 if [[ $out != *$tab* ]]; then181 while IFS='' read -r comp; do182 COMPREPLY+=("$comp")183 done < <(IFS=$'\n' compgen -W "$out" -- "$cur")184 return 0185 fi186187 local longest=0188 local compline189 # Look for the longest completion so that we can format things nicely190 while IFS='' read -r compline; do
138 unmodified lines