Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from
May 4, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions bash_completionsV2.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,14 @@ __%[1]s_handle_completion_types() {
__%[1]s_handle_standard_completion_case() {
local tab=$'\t' comp

# Short circuit to optimize if we don't have descriptions
if [[ $out != *$tab* ]]; then
marckhouzam marked this conversation as resolved.
Show resolved Hide resolved
while IFS='' read -r comp; do
COMPREPLY+=("$comp")
done < <(IFS=$'\n' compgen -W "$out" -- "$cur")
marckhouzam marked this conversation as resolved.
Show resolved Hide resolved
return 0
fi

local longest=0
# Look for the longest completion so that we can format things nicely
while IFS='' read -r comp; do
Expand Down