From ce36da4fef09ba68240762daa33d560ecf848d56 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ville=20Skytt=C3=A4?= Date: Wed, 4 May 2022 00:39:07 +0300 Subject: [PATCH] perf(bash-v2): speed up filtering entries with descriptions Use simple prefix match instead of single word `compgen -W` command substitution for each candidate match. --- bash_completionsV2.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/bash_completionsV2.go b/bash_completionsV2.go index 49d03bef6..8e22982f8 100644 --- a/bash_completionsV2.go +++ b/bash_completionsV2.go @@ -183,8 +183,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}