mirror of https://github.com/spf13/cobra.git
perf(bash-v2): read directly to COMPREPLY on descriptionless short circuit (#1700)
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.
This commit is contained in:
parent
ffa8860dbe
commit
5b11656e45
|
@ -178,9 +178,7 @@ __%[1]s_handle_standard_completion_case() {
|
||||||
|
|
||||||
# Short circuit to optimize if we don't have descriptions
|
# Short circuit to optimize if we don't have descriptions
|
||||||
if [[ $out != *$tab* ]]; then
|
if [[ $out != *$tab* ]]; then
|
||||||
while IFS='' read -r comp; do
|
IFS=$'\n' read -ra COMPREPLY -d '' < <(IFS=$'\n' compgen -W "$out" -- "$cur")
|
||||||
COMPREPLY+=("$comp")
|
|
||||||
done < <(IFS=$'\n' compgen -W "$out" -- "$cur")
|
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue