From fb8031162c2ffab270774f13c6904bb04cbba5a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ville=20Skytt=C3=A4?= Date: Wed, 4 May 2022 04:34:55 +0300 Subject: [PATCH] perf(bash-v2): speed up filtering entries with descriptions (#1689) 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 7c0b4f1..a06ab45 100644 --- a/bash_completionsV2.go +++ b/bash_completionsV2.go @@ -191,8 +191,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}