Skip to content
Myr

perf(bash-v2): read directly to COMPREPLY on descriptionless short circuit (#1700)

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

Not that it'd really matter that much performancewise given the level we are at for this case, but this change makes the short circuit roughly twice as fast on my box as it was for the 1000 rounds done in marckhouzam/cobra-completion-testing. Perhaps more importantly, this makes the code arguably slightly cleaner.

authored by Ville Skyttä · committed by GitHub · parent ffa8860 · Browse files · 1 file+1 added−3 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+1 added−3 removed

  • other:+1 added−3 removed

1 file+1 added−3 removed

modified:bash_completionsV2.go+1 added-3 removed
176 unmodified lines
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")181 IFS=$'\n' read -ra COMPREPLY -d '' < <(IFS=$'\n' compgen -W "$out" -- "$cur")182 return 0183 fi184185 local longest=0
141 unmodified lines